编程题1:输入一个年份,输出为闰年。#闰年条件:能被4整除但不能被100整除,或者能被400整除的年份都是闰年
n = eval(input("请输入一个年份:"))
if n % 4 == 0 and n %100 != 0 or n % 400 == 0:
print("{}年是闰年".format(n))
else:
print("{}年不是闰年".format(n))
output:
请输入一个年份:5000
5000年不是闰年
编程题2:最大公约数计算。获得两个整数,求出这两个整数的最大公约数和最小公倍数。最大公约数的计算一般使用辗转相除法,最小公倍数则使用两个数的乘积除以最大公约数
x=int(input('请输入一个整数:'))
y=int(input('请输入一个整数:'))