python随笔录入月份的值,输出对应的季节


 首先获取一个输入,加判断,输入对应的月份,季节判定根据气象划分法(气象划分法:在气象部门,通常以阳历3~5月为春季,6~8月为夏季,9~11月为秋季,12月~来年2月为冬季,并且常常把1、4、7、10月作为冬、春、夏、秋季的代表月份)

以下为弱基础小白实现代码:

month = int(input("请输入月份:"))
if month >= 3 and month <= 5:
    print("你输入的{}月份是春天".format(month))
elif month >= 6 and month <= 8:
    print("你输入的{}月份是夏天".format(month))
elif month >= 9 and month <= 11:
    print("你输入的{}月份是秋天".format(month))
elif month ==12 or month == 1 or month == 2 :
    print("你输入的{}月份是冬天".format(month))
else:
    print("月份输入不规范,请重新输入!")

有任何错误和不足的地方,请在下面留言指正!谢谢

   

 

原文地址:https://www.cnblogs.com/ilovezzh/p/9349850.html