#!/usr/bin/env python3#需求:确定最大值/确定最小值/然后给出索引/再用一个循环比较一下import randomtop = int(input("请填入上限:"))bom = int(input("请填入下限:"))rand = random.randint(bom, top)num = int(input("请输入您猜的数:"))if num > rand:print("猜大了")elif num < rand:print("猜小了")else: print("猜对了")while(num != rand):num = int(input("请输入您猜的数:"))if num > rand:print("猜大了")#breakelif num < rand:print("猜小了")#breakprint("猜对了")
py写个小游戏(猜数字)
时间:2023-08-11
相关推荐