Python入门之初识while循环

"""
循环语句
while 条件:
循环体
"""
# 死循环:循环条件永远是满足的。
while True:
    usd = int(input("请输入美元:"))
    print(usd * 6.9)
    if input("输入q键退出:"):
        break  # 退出循环体
# 练习:使下列代码循环执行,按e键退出。
# 调试程序
# season = int(input("请输入季度:"))
# if season == "春":
# print("1月2月3月")
# elif season == "夏":
# print("4月5月6月")
# elif season == "秋":
# print("7月8月9月")
# elif season == "冬":
# print("10月11月12月")
while True:
    season = int(input("请输入季度:"))
    if season == "":
        print("1月2月3月")
    elif season == "":
        print("4月5月6月")
    elif season == "":
        print("7月8月9月")
    elif season == "":
        print("10月11月12月")
    if input("输入e键退出") == "e":
        break

 

posted @ 2023-01-26 07:57  黎小菜  阅读(31)  评论(0)    收藏  举报