- 1
Lesson 18
I am really stuck at lesson 18, PLS HELP!!
7 Answers
+ 2
Hi,
can you post the code you tried or the question?
+ 1
bill_amount = int(input())
tip = bill_amount * 20 / 100
Print(tip)
The input function outputs always a string even if you type a number, thats why i used int() to convert string into an integer.
The variable tip calculates 20% of the input and the result will be a float because we used this â/â
0
Ferdaws Kukcha 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.
Sample Input
50
Sample Output
10.0
0
Thank you so much!! I think I added some code lol but i tried so many diff ways
0
This was the last code i tried
bill = 1
bill = bill + 25
tip = int(bill) *20/100
0
You are welcome !
We learn programming languages when we play around with the code. If you have any questions about my solution pls ask.
0
bill = 1 means you assign the value 1 to the variable bill ( the value of bill is from now on 1)
Then you say bill = bill + 25 ( remember till now bill had the value 1 and now bill = 1 + 25 which is 26 and from now on bill has the value 26)
Then you say tip = 26 * 20 / 100
But the question was that you take any number as input thats why you have to use the input function.