0

Any one can help me how to solve Flight time question in Python for Beginners course ?

30th May 2021, 6:01 AM
ch Murali
10 odpowiedzi
+ 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
30th May 2021, 6:20 AM
Ollie Q
Ollie Q - avatar
+ 4
Please show your attempts!
30th May 2021, 6:06 AM
Abhiyantā
Abhiyantā - avatar
+ 2
Distance = 7425 Speed = 550 Time_taken = float(Distance / Speed) print(Time_taken ,+"hours")
30th May 2021, 6:10 AM
ch Murali
+ 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
30th May 2021, 6:07 AM
Ollie Q
Ollie Q - avatar
+ 1
Ollie Q Rishav Tiwari I posted my code above
30th May 2021, 6:11 AM
ch Murali
+ 1
Thanks it worked Ollie Q .. Why " hours" didn't worked ?
30th May 2021, 6:19 AM
ch Murali
+ 1
#Flight Time print (7425/550) Note: Show your attempt.
30th May 2021, 6:21 AM
‎ ຸ
0
Try removing the ,’ “hours”’
30th May 2021, 6:17 AM
Ollie Q
Ollie Q - avatar
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")
31st May 2021, 11:07 PM
Benjamin Rogers
Benjamin Rogers - avatar
0
Oh ok .. I had forgotten about concatenation in Python .. Thanks a lot Benjamin Rogers
1st Jun 2021, 2:05 AM
ch Murali