Python for beginners | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
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