if 条件: 满足条件执行代码elif 条件: 上面的条件不满足就走这个elif 条件: 上面的条件不满足就走这个elif 条件: 上面的条件不满足就走这个 else: 上面所有的条件不满足就走这段
age_Lao=23 age_Lao_chun=int(input("猜猜我的年龄:")) #input用户导入输入 if age_Lao_chun==age_Lao: print("恭喜你猜对了") elif age_Lao_chun>age_Lao: print("往小一点猜嘛") elif age_Lao_chun
score=int(input("请输入分数线:")) if score>=100: print("A") elif score>=90: print("B") elif score>=80: print("C") else: print("课程结束了") 密码加密模块
import getpass #getpass 密码密文 username=input("username:") password=getpass.getpass("password:") print(username,password)
while循环语句
age_Lao=23 count=0 while count<3: #做出判断猜错三次提出 age_Lao_Chun=int(input("请输入我的年龄:")) if age_Lao_Chun==age_Lao: print("你好聪明啊") break #猜对了退出循环 elif age_Lao_Chun>age_Lao: print("猜小一点嘛") else: print("猜大一点嘛") count+=1 #与上面count做判断
一到一百依次打印
number=1 while number<101: print(number) number+=1
number=0 while number<10: number+=1 if number==7: #判断number==7 continue # 如果==7 就跳出循环执行下次循环 print(number) 一到一百的总数
number_sum=0 number=1 while number<101: number_sum+=number number+=1 print(number_sum) 一到一百的偶数
number_1=1 while number_1<=100: if number_1 % 2 ==0: print(number_1) number_1+=1 一到一百的奇数
number_1=1 while number_1<=100: if number_1 % 2!=0: # 2!=0 是除以2不来 print(number_1) number_1+=1