guess_procedure

初学Python自己默写的小程序;虽然对很多人太简单,但对我这种小白,还是自己纪念一下;

 1 #猜数字游戏;
 2 import random
 3 number = random.randint(1,10)            #调取模块,随机1-10数字;
 4 count = 0 
 5 while count < 6 :                        #while循环只能玩6次;
 6     guess = input("Please enter the number you want to guess:") 
 7     if guess < number:
 8          print("Your guess is too big!")
 9     elif guess > number:
10          print("Your guess is too small!")
11     else:
12          print("Congratulations on your guess!")
13      count +=1                            #计数器增加,机会少了一次;
14 print("Game Over!")

有时候看视频或听老师讲,感觉都听明白了,但临到自己写的时候却写不上来了,努力中,先模仿别人写的,然后背下来自己写,最后希望能到达自己写出来;

猜你喜欢

转载自www.cnblogs.com/PooChai/p/9262538.html