话不多说直接上代码
import time
import random
print('-*- 猜数字 -*-')
big = int(input('请输入最大数'))
small = int(input('请输入最小数'))
if big <= small:
while True:
print('最大数不能与最小数一致或小于')
print('请重新输入最大数')
big = int(input())
small = int(input('请重新输入最小数'))
if big != small:
break
if big % 1 or small % 1:
while True:
print('最大数或最小数必须为整数')
print('请重新输入')
big = int(input())
small = int(input())
if big %1 == 0 or small %1 == 0:
break
p = int(random.randint(small,big))
print('请输入你猜的数')
response = int(input())
if response != p:
while True:
if response > p:
print('你猜的数大了')
print('请重新输入')
response = int(input())
elif response < p:
print('你猜的数小了')
print('请重新输入')
response = int(input())
elif response == p:
print('恭喜你猜对了')
break
if response == p:
print('恭喜你猜对了')