概述
import random
import random
# 游戏1.0 完成游戏
# 游戏2.0 提示机会次数,
# 游戏3.0 猜中了就结束游戏
# 游戏4.0
# 1。电脑出一个1-100的随机数
computer=random.randint(1,10)
# for 循环
# 2。你猜一个数字
# break
跳出所有循环,不再执行
# continue 跳出当前循环,进行下一次循环
chance = 10
max_num = 10
min_num = 1
for a in range(10):
print("---------你还有%d次机会-------"%chance)
chance = chance-1
s = input("请猜数字从%d到%d:"%(min_num,max_num )) # 进行提示
s = int(s)
# 3。判断:电脑进行判断是否猜中,还是猜大了或者猜
if s == computer:
if a == 0:
print('天选之人')
else:
print('你猜中了')
break
elif s > computer:
print('你猜的数字大了')
max_num = s
else:
print('你猜的数字小了')
min_num = s
import random
# 游戏1.0 完成游戏
# 游戏2.0 提示机会次数,
# 游戏3.0 猜中了就结束游戏
# 游戏4.0
# 1。电脑出一个1-100的随机数
computer = int(input("请出一个数字") )
# for 循环
# 2。你猜一个数字
# break
跳出所有循环,不再执行
# continue 跳出当前循环,进行下一次循环
chance = 10
max_num = 1000
min_num = 1
for a in range(10000):
chance = chance-1
s = random.randint(1, 100)
# 3。判断:电脑进行判断是否猜中,还是猜大了或者猜
if s == computer:
if a == 0:
print('天选之人')
else:
print('你猜中了')
break
elif s > computer:
print('你猜的数字大了')
max_num = s
else:
print('你猜的数字小了')
min_num = s
print("电脑猜了%d次机会-------"%a)
3.0
import random
import easygui
easygui.msgbox("harry,我们将进行猜数字游戏,准备好了吗")
computer = random.randint(1,100)
# 在窗口里输入数字
while True:
s = int(easygui.enterbox("你想猜多少"))
if s == computer:
if 1:
easygui.msgbox('天选之人')
else:
easygui.msgbox('你猜中了')
break
elif s > computer:
easygui.msgbox('你猜的数字大了')
max_num = s
else:
easygui.msgbox('你猜的数字小了')
min_num = s
最后
以上就是能干小蚂蚁为你收集整理的harry-猜数字游戏(未完待续)的全部内容,希望文章能够帮你解决harry-猜数字游戏(未完待续)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复