+ 1

# Code Coach: How Many Miles?

Iâm doing the first code coach for Python 5.1. It asks: Calculate and output the number of miles in 1000 kilometers. Hint One mile is 1.6 kilometers, so find the quotient of 1000 and 1.6. I looked at my calculator beforehand and saw that 1000/1.6 is 625.0, no remainders, so why is it wrong when i do print(1000/1.6) and it displays 625.0, but right when i do print(1000//1.6) and it displays 624.0 when itâs mathematically wrong?

3 Answers

0

print(1000/1.6-1) # This answer also works, fooling the program asking to use "//" jaja
It seems that you are right, so curious...
https://www.wolframalpha.com/input/?i=1000%2F1.6+is+an+integer%3F

0

Hi James Nguyen ,
Because integer / float is float
And because the result will be float, // rounds it down so 265.0 becomes 264.0

0

#your code goes here
x=1000
y=1.6
print (x//y)