# 竞猜幸运大乐透
"""
# 整数10-20
print(random.randint(10, 20))
# 0-1
print(random.random())
# 浮点数10-20
print(random.uniform(10, 20))
"""
import random
while True:
num1 = input("请输入1号玩家您的幸运数字(输入q/Q退出!)")
if num1.lower()=='q':
break
num2 = input("请输入2号玩家您的幸运数字(输入q/Q退出!)")
if num2.lower()=='q':
break
before_num1 = random.randint(1, 20)
after_num1 = random.randint(1, 20)
if before_num1 > after_num1:
print(f"{before_num1} > {after_num1}:1号玩家胜利!")
elif before_num1 == after_num1:
print(f"{before_num1} = {after_num1}:平局!!!")
elif before_num1 < after_num1:
print(f"{before_num1} < {after_num1}:2号玩家胜利!")
py050:随机数的生成与比较
最新推荐文章于 2024-11-14 13:48:50 发布