python - 从 3 个数字中找出最大的数字
问题描述
我正在尝试使用 python3.6 找到最大的 3 个数字。但它返回错误的值。
#!/usr/bin/python3
a=input("Enter first number: ")
b=input("Enter second number: ")
c=input("Enter Third number: ")
if (a >= b) and (a >= c):
largest=a
elif (b >= a) and (b >= c):
largest=b
else:
largest=c
print(largest, "is the greatest of all")
如果我提供,a=15;b=10 和 c=9 预期输出应为 15。
但我得到的实际输出为 9。
解决方案
您可以使用 python 的 max() 内置函数: https ://www.freecodecamp.org/forum/t/python-max-function/19205
推荐阅读
- mysql - 如何从 sql 语句中添加新列?
- oracle - Oracle 位置和索引
- java - 如何正确设置 Maven Spring Boot 多模块项目?
- c++ - 来自csv文件的C ++中多维数组的总和
- git - 是否有自动增加 Maven 版本的好方法
- java - 如何使用通知侦听器服务在动态生成的文本视图中使用
- wordpress - 如何在我的 wordpress 网站中阻止未知广告的弹出窗口
- ios - 音频播放器需要一段时间才能加载
- entity-framework-core - 在 DbContext 级别添加包含
- javascript - 使这些 div 可点击 jsonparse