f = open(r'文件.txt','r')
string = f.read()
f.close()
lst = list(map(int,string.split()))
#判断奇偶
def parity(n):
if n%2:
return 1
else:
return 0
#判断质合
def qualitatively(n):
if n == 1 or n == 0:
return 2
elif n>1:
for i in range(2, n//2+1):
if (n % i) == 0:
return 0
else:
return 1
#合数奇偶
def check(n):
temp = n//10+n%10
if temp %2:
return 1
else:
return 0
#运算函数
def main(fun):
for i in range(len(lst)):
print(fun(lst[i]),end = ' ')
if (i+1)%6 == 0:
print('\n')
if __name__ == '__main__':
print('='*25,'奇偶判断','='*25)
main(parity)
print('='*25,'质合判断','='*25)
main(qualitatively)
print('='*25,'合数奇偶','='*25)
main(check)
|