Bootstrap

python 简单demo -- 猜数字 python编程:从入门到实践

自己书写的源码:

from random import randint

 

def guess():

a = randint(1,100)

b=int(input("I'm thinking of a number! Try to guess the number I'm thinking of:"))

while True:

if a == b:

again=input('That"s it! Would you like to play again?(yes/no)')

break

elif a>b:

b = int(input('Too low! Guess again:'))

else:

b = int(input('Too Hign! Guess again:'))

if again == 'no':

print('Thanks for playing')

elif again == 'yes':

guess()

guess()

 

 

;