首页 > 文章列表 > 如何比较三个数字的大小在Python

如何比较三个数字的大小在Python

Python 精选
168 2024-04-13

python怎么判断三个数的大小

可以使用如下代码来判断三个数的大小:

a = int(input("请输入第一个整数:"))
b = int(input("请输入第二个整数:"))
c = int(input("请输入第三个整数:"))

if a > b and a > c:
print(f"{a}最大")
elif b > a and b > c:
print(f"{b}最大")
else:
print(f"{c}最大")

用户输入三个整数后,程序会比较这三个数的大小,并输出最大的数。