0
Any one can help me how to solve Flight time question in Python for Beginners course ?
10 ответов
+ 2
That is because it just asked for the number and no other formating so your number was correct but the addition of “hours” made it mark it incorrect because it just wanted the number
+ 4
Please show your attempts!
+ 2
Distance = 7425
Speed = 550
Time_taken = float(Distance / Speed)
print(Time_taken ,+"hours")
+ 1
Hi ch Murali
Your attempt would be nice to see first. I assume your issue is with math in that case it should be distance divided by time
+ 1
Ollie Q Rishav Tiwari
I posted my code above
+ 1
Thanks it worked Ollie Q ..
Why " hours" didn't worked ?
+ 1
#Flight Time
print (7425/550)
Note: Show your attempt.
0
Try removing the ,’ “hours”’
0
ch Murali You have a TypeError in your print statement. You can't concatenate a float with a string type. You need to cast the float to a string, then concatenate them.
print(str(Time_taken) + " hours")
0
Oh ok .. I had forgotten about concatenation in Python .. Thanks a lot Benjamin Rogers