Новый курс! Каждый программист должен знать генеративный ИИ!
+ 3

# What is the right answer of flight time quize

distance=7425 speed=550 time=(distance//speed) print(time 'hour')

15th Jul 2021, 10:35 AM
Jupi
12 ответов
+ 4
Jupitora Roy distance is 7425 And also use normal division (/) There are two type of division 1 - normal division (/) which gives result with decimal 2 - floor division (//) which gives result without decimal So for example: print (5 / 2) = 2.5 print (5 // 2) = 2
15th Jul 2021, 10:50 AM
A͢J
+ 3
now correct the integer division to the normal division
15th Jul 2021, 10:43 AM
Yaroslav Vernigora
+ 3
15th Jul 2021, 10:57 AM
Kshitiz
+ 2
print(time)
15th Jul 2021, 10:37 AM
Yaroslav Vernigora
+ 2
now correct the integer division to the normal division Thanks Yaroslav Vernigora
15th Jul 2021, 10:58 AM
Jupi
15th Jul 2021, 10:59 AM
Jupi
+ 2
Kshitiz Ya answer is 1 hour
15th Jul 2021, 11:02 AM
Jupi
+ 1
Thanks.
15th Jul 2021, 11:04 AM
Kshitiz
0
distance=742 speed=550 time=(distance//speed) print(time ) Is not working
15th Jul 2021, 10:42 AM
Jupi
0
// means quotient
15th Jul 2021, 10:56 AM
Kshitiz
0
#We declare and assign our variables to int type values distance = 7425 speed = 550 #**************************** Notice**********************************# """ There are 3 types of division operations: - Normal division (/): Gives the exact quotient(in decimal form) e.g: 7/2 = 3.5 Floor division (//): Similar to division but returns the largest possible integer. e.g: 7//2 = 3 Modulus(%): returns the remainder of floor division. e.g: 7%2 = 1 """ #define our operation which returns either the approximate number of hours or #the exact number depending on question time = (distance // speed) 'Or: time = (distance / speed) for exact value Or for those who like complicating things ;-): checker = distance % speed #If you want approx number of hours rounded up if Checker == 0: time = (distance / speed) print(str(time) + " hour(s)") #If you want approx number of hours rounded up elif Checker > 0: time = (distance // speed) + 1 # No '+1' print(str(time) + " hour(s)") ' I am not sure this method of concatination in the print function; print(time 'hour') is correct(Maybe the source of error) You could use : + operator. join() method. % operator. format() function. f-string (Literal String Interpolation) You can find out more abut this on this page: https://www.journaldev.com/23575/JUMP_LINK__&&__python__&&__JUMP_LINK-string-concatenation
16th Jul 2021, 2:35 PM
Mendjemo Ngangom Gerard Ledoux
0
This is correct Answer 👇👇👇👇👇 print(7425 / 550)
17th Jul 2021, 9:38 AM
Uddipta Kashyap