问题如下:
假设1英尺=.3048米,请编写一个Python脚本,将以米为单位给出的身高转换为以英尺和英寸表示的身高。
我看了一下教授当天给的笔记,并按照每个步骤进行了操作,但我的程序似乎无法正常工作。这是我的代码:
print("This program will convert a height given meters to a height given in feet and inches.")
meters = float(input("Enter height in meters:"))
meters_in_ft = meters // .3048
meters_in_in = meters_in_ft % 12
print("The height is", meters_in_ft,"feet and",meters_in_in, "inches")
当我运行程序并输入某些米数时,能够正确地将其转化为英尺,但很多情况下,英寸的计量值是错误的。