猜数游戏代码
import random
guess = random.randint(1,100)
print (‘猜数游戏!’)
sum=1
while(1,SUM<=5):(加粗的部分为设置的次数)
a = input(‘请输入一个整数:’)
if(a == ‘退出’):
exit(0)
elif(int(a) > guess):
print(‘偏大!’)
SUM=SUM+1
elif(int(a)< guess):
print (‘偏小!’)
SUM=SUM+1
elif(int(a) == g
原创
2020-11-09 18:27:05 ·
626 阅读 ·
0 评论