I am conversting a float to integer in the below code. But , the resultant output is not correct for nickels.
Code:
actual = 25
paid = 26.65
cents = (paid-actual)*100
quarters = int(cents/25)
cents = cents %25
dimes = int(cents/10)
cents = cents %10
nickels = int(cents/5)
print quarters, dimes, nickels,cents
print 5.0/5,int(5.0/5)
Ouput:
6 1 0 5.0
1.0 1
Expected output
6 1 1 5.0
1.0 1
If i explicitly do int(5.0/5) I get 1 , but when the same is done assigned to a variable in my code, I get 0 . I am not sure why. Can someone explain ?