到家,开电脑,已然10点,真想躺在床上刷个视频刷到睡着。想想还是坚强的坐起来,开始coding。
题目一:判断一个年份是不是闰年。 能被4整除且不能被100整除,或者能被400整除
year1=input("pleade input the year:")
year2 = int(year1)
if year2%4==0 and year2%100!=0 or year2%400==0:
print ("year:%d is leap year" %year2)
else:
print("year:%d is not leap year" %year2)
题目二:打印三角形
正三角形
for num in range(1,10):
j="*"
for i in range(1,num):
j=j+" *"
print j
倒三角形
for num in range(1,10):
for i in range(0,10-num):
print '*',
print '*'
print '*'
网友评论