1、输入某年某月某日,判断这一天是这一年的第几天?
leap_year = [31,29,31,30,31,30,31,31,30,31,30,31]#闰年 common_year = [31,28,31,30,31,30,31,31,30,31,30,31]#平年 year = int(input("type the year:")) month = int(input("type the month:")) day = int(input("type the day:")) sum = 0 if (year%4==0) and (year%100!=0) or (year%400==0): for i in range(0,month-1): sum +=leap_year[i] print("it‘s the {}th day".format(sum+day)) else: for i in range(0,month-1): sum +=common_year[i] print("it‘s the {}th day".format(sum+day))
2、输入三个整数x,y,z,请把这三个数由小到大输出。
x = int(input("type a number:")) y = int(input("type a number:")) z = int(input("type a number:")) print(sorted([x,y,z]))
3、九九乘法表。
for i in range(1,10):for j in range(1,i+1): print("{}*{}={}\t".format(i,j,i*j),end="") print()
4、暂停一秒输出。
import time import random for i in range(10): print(i) time.sleep(random.randint(0,9))
5、
原文:https://www.cnblogs.com/yijierui/p/13019523.html