|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
求助各路大神,零基础学python第五课动动手1题为什么我的结果不管输入什么都显示不是闰年?
year = input('请输入年份判断是否为闰年:')
while not year.isdigit():
print("输入有误!")
year = input('请输入一个整数:')
num = int(year)
if isinstance ((num/400),int):
print(year + "是一个闰年。")
else:
if isinstance ((num/4),int) and isinstance ((num/100),float):
print(year + "是一个闰年。")
else:
print(year + "不是一个闰年。")
#//1、能整除4且不能整除100 2、能整除400
times = 10
while times > 0:
times = times - 1
print('请输入年份',end='')
temp = input()
if temp.isdigit() == False:
print('请输入数字:',end='')
else:
year = int(temp)
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print(year,'是闰年')
else:
print(year,'不是闰年')
else:
print(year,'是闰年')
else:
print(year,'不是闰年')
print('程序结束')
|
|