zoukankan      html  css  js  c++  java
  • if语句简单练习

    1. input练习
    # -*-coding:utf-8 -*-
    # import getpass     隐藏只能在cmd中使用
    user=input("请输入账号:")
    
    password=input("请输入密码:")
    print(user)
    print(password)
    

    2.if elif 语句

    # -*-coding:utf-8 -*-
    age=int(input("请输入年龄:"))
    if age>=18:
        print("你可以去网吧了")
    elif age>=15:
        print("你可以谈恋爱了")
    elif age>=12:
        print("你可以去上学了")
    
    1. if else 语句
    # -*-coding:utf-8 -*-
    age=int(input("请输入年龄:"))
    if age>=18:
        print("你可以去网吧了")
    else:
        print("你不能去网吧")
    
    1. if elif else 语句
    # -*-coding:utf-8 -*-
    age=int(input("请输入年龄:"))
    if age>=18:
        print("你可以去网吧了")
    elif 12<age<18:
        print("你可以上初中了")
    else:
        print("你可以上小学了")
    
    1. if 嵌套语句
    # -*-coding:utf-8 -*-
    age=int(input("请输入年龄:"))
    if age>=18:
        print("你可以去网吧了")
        if age>22:
            print("你可以结婚了")
        else:
            print("你可以谈恋爱了")
    else:
        print("你还未成年")
    
  • 相关阅读:
    E
    D
    C
    B
    Python
    IDEA 设置资源目录
    光猫指示灯含义
    IO模型
    Linux 总目录
    Linux python 使用
  • 原文地址:https://www.cnblogs.com/lav3nder/p/11121774.html
Copyright © 2011-2022 走看看