1.运行结果
2. 源代码如下
import random
n = random.randint(0, 9)
count = 0
print(n)
s = int(input("please enter a number!: \n"))
while True:if 0 <= s <= 9 and s != n:if s > n:count += 1print("is bigger")else:count += 1print("is smaller")s = int(input("please enter a number!: \n"))elif s == n:count += 1print(f"ok enter_times : {count}")breakelse:print("enter error!")s = int(input("please enter a number!: \n"))