heiheihei. 2022-10-04 10:51 采纳率: 100%
浏览 31
已结题

python直角三角形打印结果

import math
bottom = float(input('3'))
height = float(input('4'))
hypotenuse = math.sqrt(bottom**2+height**2)
print(bottom, height, hypotenuse)

为什么运行结果是3啊,打印的结果不应该是底,高,开平方的斜边吗?为什么print的结果只有3啊,求解,感谢

  • 写回答

2条回答 默认 最新

  • 爱音斯坦牛 全栈领域优质创作者 2022-10-04 10:54
    关注

    错误用法,input括号里是输入的提示信息,而数值是在控制台输入的哇。你这样写没有问题,但你控制台输入数值了嘛?

    import math
    bottom = float(input("请输入底:"))
    height = float(input("请输入高:"))
    hypotenuse = math.sqrt(bottom**2+height**2)
    print(bottom, height, hypotenuse)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月12日
  • 已采纳回答 10月4日
  • 创建了问题 10月4日