while循環(huán)
語(yǔ)法:
while 條件:
語(yǔ)句
print("any")
print("any")
猜年齡
age = 50
#user_input_age = int(input("Age is :"))
flag = True
while flag:
user_input_age = int(input("Age is :"))
if user_input_age == age:
print("Yes")
flag =False
elif user_input_age > age:
print("Is bigger")
else:
print("Is smaller")
print("End")
break 終止后添;continue 繼續(xù)
循環(huán)打印99乘法表
height = 1
while height <= 9:
tmp = 1
while tmp <= height:
print(str(height) + "*" + str(tmp) + "=" + str(height * tmp), end="\t")
tmp += 1
print()
height += 1