首页 > 代码库 > Python:if-while-for

Python:if-while-for

#!/usr/bin/python3#if elif elseprint("开始猜数字游戏")num = int(input("请输入数字"))stand = 30if num == stand:    print("你猜对了")elif num<stand:    print("猜小了")else:    print("猜大了")#whilen=1count =0while n<=100:    count+=n    n+=1print("1-100的和等于=",count)#for#计算1-100的和 count =0 ;for i in range(101):    count=count+iprint("1-100的和等于=",count)#break continue

 

Python:if-while-for