データグループ6月Python審査任務
2367 ワード
タスク要件
インプリメンテーション
a.py
b.py
1. ,
2. , Yes, No
3. ,
4. 20
5. ( )
6. a.py
7. b.py a.py , 1-5 ,
インプリメンテーション
a.py
def calculator():
a, b, c = eval(input(' , :'))
if a+b > c and b+c > a and c+a > b:
C = a + b + c
p = C/2
S = pow(p*(p-a)*(p-b)*(p-c), 0.5)
return C, S
def is_prime():
from math import sqrt
n = eval(input(' :'))
for i in range(2, int(sqrt(n))+2):
if n%i == 0:
print('No')
break
else:
print('Yes')
def zdgys(m, n):
while m%n != 0:
m, n = n, m%n
return n
def zxgbs(m, n):
return m * n // zdgys(m, n)
def fibo(n):
if n == 1 or n == 2:
return 1
else:
return fibo(n-1) + fibo(n-2)
def wordshow():
from time import sleep
s = ' '
while True:
s = s[1:] + s[0]
print('\r{}'.format(s), end='')
sleep(0.2)
b.py
import a
print(' :')
print('1. , ')
print('2. , Yes, No')
print('3. , ')
print('4. 20 ')
print('5. ')
while True:
input_num = eval(input(' :'))
if input_num == 1:
C, S = a.calculator()
print(' :{}, :{}。'.format(C, S))
elif input_num == 2:
a.is_prime()
elif input_num == 3:
p, q = eval(input(' , :'))
Ma=a.zdgys(p, q)
mi=a.zxgbs(p, q)
print(' :{},
:{}。'.format(Ma,mi))
elif input_num == 4:
for i in range(1,21):
print('{:05}'.format(a.fibo(i)),end=' ')
if i%5 == 0:
print()
elif input_num == 5:
a.wordshow()
else:
print(' , ')
print(' :')
print('1. , ')
print('2. , Yes, No')
print('3. , ')
print('4. 20 ')
print('5. ')