Jan-11-2018, 07:24 AM
For some reason, it's not letting me concatenate a float in my print statement on line 6:
#!/usr/bin/env python3 #BasicUserInterface.py #MACH 1 = 761.2071 mph #1 mph = MACH 0.0013 def calculateMACH(mph): mach = mph * 0.0013 return mach def calculateTime(mph, distance): time = distance / mph return time def calculateMinutes(mph, distance): time = distance / mph milesPerMinute = time / 60 return milesPerMinute def main(): choice = "y" while choice.lower() == "y": mph = float(input("Enter speed in mph:")) distance = float(input("Enter number of miles to destination:")) mach = calculateMACH(mph) time = calculateTime(mph, distance) milesPerMinute = calculateMinutes(mph, distance) if mph > 761.2071: print("You are traveling faster than the speed of sound!") print("You are traveling at MACH " + str(mach)) print("At that speed, you should reach your destination in " + str(round(time, 2)) + " hours, or " + str(round(milesPerMinute, 2) + " minutes.")) choice = input("Do you want to continue? (y/n)") print() print("Bye!") if __name__ == "__main__": main()
Error:===== RESTART: I:/Python/Python36-32/SamsPrograms/BasicUserInterface.py =====
Enter speed in mph:60
Enter number of miles to destination:60
You are traveling at MACH 0.078
Traceback (most recent call last):
File "I:/Python/Python36-32/SamsPrograms/BasicUserInterface.py", line 44, in <module>
main()
File "I:/Python/Python36-32/SamsPrograms/BasicUserInterface.py", line 36, in main
str(round(milesPerMinute, 2) + " minutes."))
TypeError: unsupported operand type(s) for +: 'float' and 'str'
What's wrong?