zoukankan      html  css  js  c++  java
  • if 条件判断和for 循环

    if 条件判断

    if 判断条件:
    	执行代码
    elif 判断条件:
    	执行代码
    else:
        执行代码
    
    choise = True
    while choise == True:
        grade = int(input("请输入成绩: ").strip())
        if grade == 111:
            choise = False
            continue
        if grade >= 90:
            print('优秀!')
        elif grade >= 80:
            print('良好!')
        elif grade >= 70:
            print('普通!')
        else:
            print('差!')
    

    for 循环

    list = [4,6,9,11]
    for i in range(1,13):
        for j in range(1,32):
            if i in list :
                if j == 31:
                    break
            if i == 2 and j == 29:
                break
            print(f"{i}月{j}号")
    
    

    判断是否闰年

    while True:
        year = int(input("输入年份: "))
        if year % 100 == 0:
            if year % 400 == 0:
                print('是闰年!')
            else:
                print('不是闰年!')
        elif year % 4 == 0:
            print('是闰年!')
        else:
            print('不是闰年!')
    
        if year == 1:
            break
    
  • 相关阅读:
    密码加密
    注册视图
    session会话
    验证码功能
    使用Django表单替代html表单
    实现登陆视图功能
    设计登陆需求页面
    配置视图
    配置数据库
    npm 学习
  • 原文地址:https://www.cnblogs.com/shenblog/p/11424140.html
Copyright © 2011-2022 走看看