Wind Chill 计算器和定义中的数学公式
Wind Chill Calculator and math formulas in definitions
这应该是我遇到的最后一个错误
velocity = wind_speed * 0.16
TypeError: can't multiply sequence by non-int of type 'float'
有什么想法吗?很确定我需要将输入定义为浮点数,对不起,我还是 python.
的新手
def calc_wind_chill(f_temp, wind_speed):
""" float, float -> float
returns wind_chill_temperature (F)
given farenheit temperature and
wind_speed in miles per hour
"""
velocity = wind_speed * 0.16
chill = 35.74 + (0.6215 * f_temp)-(35.75 * velocity) +(0.4275 * f_temp * velocity)
return chill
#end def
while True:
question=input("w for windchill or q for quit: " )
if question=="w":
temperature=input("Air tempature in Fahrenheit: ")
wind=input("What is the windspeed in mph: ")
calc_wind_chill(temperature, wind)
print("Wind Chill", chill, " F", temperature, "F ", "wind speed:", wind)
wind_chill_2= calc_wind_chill(temperature, wind +10)
print("wind Chill:", wind_chill_2, " F", temperature, "F ", "wind speed:", wind + 10)
elif question=="q":
print("have a nice day!")
break
函数内部的所有内容,包括注释,都需要缩进...
def calc_wind_chill(f_temp, wind_speed):
""" float, float -> float
returns wind_chill_temperature (F)
given farenheit temperature and
wind_speed in miles per hour
"""
velocity = wind_speed ** 0.16
chill = 35.74 + (0.6215 * f_temp)-(35.75 * velocity) +(0.4275 * f_temp * velocity)
return chill
这应该是我遇到的最后一个错误
velocity = wind_speed * 0.16
TypeError: can't multiply sequence by non-int of type 'float'
有什么想法吗?很确定我需要将输入定义为浮点数,对不起,我还是 python.
的新手def calc_wind_chill(f_temp, wind_speed):
""" float, float -> float
returns wind_chill_temperature (F)
given farenheit temperature and
wind_speed in miles per hour
"""
velocity = wind_speed * 0.16
chill = 35.74 + (0.6215 * f_temp)-(35.75 * velocity) +(0.4275 * f_temp * velocity)
return chill
#end def
while True:
question=input("w for windchill or q for quit: " )
if question=="w":
temperature=input("Air tempature in Fahrenheit: ")
wind=input("What is the windspeed in mph: ")
calc_wind_chill(temperature, wind)
print("Wind Chill", chill, " F", temperature, "F ", "wind speed:", wind)
wind_chill_2= calc_wind_chill(temperature, wind +10)
print("wind Chill:", wind_chill_2, " F", temperature, "F ", "wind speed:", wind + 10)
elif question=="q":
print("have a nice day!")
break
函数内部的所有内容,包括注释,都需要缩进...
def calc_wind_chill(f_temp, wind_speed):
""" float, float -> float
returns wind_chill_temperature (F)
given farenheit temperature and
wind_speed in miles per hour
"""
velocity = wind_speed ** 0.16
chill = 35.74 + (0.6215 * f_temp)-(35.75 * velocity) +(0.4275 * f_temp * velocity)
return chill