#!/usr/bin/env python
‘’’
计算出0—20之间所有的偶数
计算出0—20之间的所有奇数
计算出一个整数是否可以被另外一个整数整除
‘’’

def oushu(x,y):
a=[]
for i in range(x,y+1):
if i%2==0:
a.append(i)
else:
pass

return a

def jishu(x,y):
a=[]
i=x
while i<y+1:
if i%21:
a.append(i)
else:
pass
i=i+1
return a
#判断是否可以整除,可以被整除则为True,不能被整除则为False
def zhengchu(x,y):
if x%y
0:
return True
elif y%x==0:
return True
else:
return False

if name"main":
print(oushu(0,20))
print(jishu(0,20))
new1=input(“please input the first number:”)
new2=input(“please input the second number:”)
a=zhengchu(int(new1),int(new2))
if a
True:
print("{}和{}能够互相被整除".format(new1,new2))
else:
print("{}和{}不能够互相被整除".format(new1,new2))

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐