py写个小游戏(数字炸弹)

引入了time.sleep,强制延时1s

#!/usr/bin/env python3

import random
import time

start = 0
end = 99
boom = random.randint(0, 99)

while 1==1:
	people = int(input("填入{}到{}之间的数".format(start, end)))
	if people > boom :
		print("大了")
		end = people
	elif people < boom :
		print("小了")
		start = people
	else:
		print("BOOM!")
		break
	print("等待电脑输入{}到{}之间的数".format(start, end))
	time.sleep(1)
	com = random.randint(start, end)
	print("电脑输入为{}".format(com))
	if com > boom :
		print("大了")
		end = com
	elif com < boom :
		print("小了")
		start = com
	else:
		print("BOOM!")
		break

你可能感兴趣的:(python复建,python,开发语言,后端)