python学习-input函数、while循环、break语句、关系符

一、学习内容

1、input函数值类型为字符串

2、while循环:为真时一直循环,使用break语句跳出循环

3、关系符

二、作业:写一个猜数字的小游戏,猜错三次则退出,要求使用input函数、while循环语句、if else语句

def Game(count):
count = int(input("please insert the value:"))

while count > 0:
guess = int(input("please insert your value:"))
if guess == 8:
print("right")
print("over")
break
elif guess > 8:
print("too big")
else:
print("too small")
count -= 1
if count == 0:
print("no chance,over")

if __name__ == "__main__":
Game(3)
原文地址:https://www.cnblogs.com/LM791605490/p/14787981.html