- 1

What mistake I have made in this code for question given below. bill = int(input()) x=float((bill*20)//100) print(x)

Q was to take input from user for bill of order and calculate 20% tip on it in float

17th Jun 2021, 9:06 AM
Piyush Verma
3 Answers
+ 6
x=float((bill*20)/100)
17th Jun 2021, 9:25 AM
Simba
Simba - avatar
+ 6
Yes, but decimals will be lost(truncated) if we use floor division(//) instead of division operator(/) x = 8*20/100 y = 8*20//100 print(float(x)) print(float(y))
17th Jun 2021, 10:08 AM
Simba
Simba - avatar
- 1
but to get the quotient shouldn't we have put //
17th Jun 2021, 9:47 AM
Piyush Verma