随机生成月份,判断季节
import random
#随机生成月份,判断季节
month = random.randint(1,12)
#3-5
if month>=3 and month<=5:
print(str(month)+'春季')
elif month>=6 and month<=8:
print(str(month)+'夏季')
elif month>=9 and month<=11:
print(str(month)+'秋季')
else:
print(str(month)+'冬季')
求阶乘!
def get_factorial(num):
factorial = 1
for i in range(num):
factorial*=(i+1)
return factorial
测试
f = get_factorial(10)
print('10!='+str(f)) #print('10!='+str(get_factorial(10)))