这是我到目前为止的代码,当我运行它时出现语法错误,我不知道为什么
#input from the user
def main()
miles = float(input("Enter a distance in miles: "))
conv_fac = 1.609 #conversion factor
#calculating how many kilometers
kilometers = miles * conv_fac
print("The distance in kilometers is: ", kilometers)
main()
答案 0 :(得分:1)
您未在:
功能后添加main()
个符号
应该是
#input from the user
def main():
miles = float(input("Enter a distance in miles: "))
conv_fac = 1.609 #conversion factor
#calculating how many kilometers
kilometers = miles * conv_fac
print("The distance in kilometers is: ", kilometers)
main()
这是结果:
答案 1 :(得分:-1)
def convert_to_miles(miles):
return miles * 1.6
print convert_to_miles(miles)