猜数字小游戏:1-10随机数字,玩家输入猜测的数字,如果没有猜中,则给出大于或小于以便缩小范围,直至猜中。
注:就是最基本的代码,可以在此基础上进行加工,例如增加猜测次数限制等。
# -*- coding:utf-8 -*-
# coding=utf-8
# coding:utf-8
import random
print("欢迎加入猜数字游戏,数字范围为1-10")
num = random.randint(1,10)
while True:
temp = input("请输入你猜的数字:\n")
guess =