+ 1

Python for beginners

Please can someone explain how to solve this When you go out to eat, you always tip 20% of the bill amount. But who’s got the time to calculate the right tip amount every time? Not you that’s for sure! You’re making a program to calculate tips and save some time. Your program needs to take the bill amount as input and output the tip as a float.

2nd Mar 2022, 5:40 PM
Ofere Believe
Ofere Believe - avatar
4 Respuestas
0
* get input * convert input to a numeric data type * calculate 20% of this * output the result
2nd Mar 2022, 5:50 PM
Lisa
Lisa - avatar
0
I did this and it was still an error bill = float(input(1000 * 20/100)) Print(bill)
2nd Mar 2022, 6:24 PM
Ofere Believe
Ofere Believe - avatar
0
input() takes user input – do not write inside of this function! First take input and convert it, THEN calculate with it: bill = float(input()) * 0.2 Also, I don't understand why you put 1000 there? 20% means 20/100 or 0.2
2nd Mar 2022, 6:32 PM
Lisa
Lisa - avatar
0
Thank you Lisa
3rd Mar 2022, 4:53 AM
Ofere Believe
Ofere Believe - avatar