+ 1
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 ti
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
17 Antworten
+ 4
Your code must meet the conditions in the task description to solve the task: only input as described and only output as described
+ 1
Please show your code so we can help you to solve the task
0
Your calculation is currently a string â remove '' to output the result
0
Please explain briefly
0
I am a beginner
0
Remove the '' to output the number.
print() is a function not a variable, so it is print(something)...
0
Read the task description again: input is bill, there isn't any 2nd input.
print is a function to print the result and remove the ' inside of print()
0
Please read the task description and my comments carefully.
If you still have problems, show us your updated code.
0
Hi mahendra nag, I think you didn't learnt the Python syntaxes clearly,
In your code you have wrote to take first input as bill okay it's right
Now no need to take second input as it's given that's the tip is 20%, the user don't have to input the tip, so correct it
Now you are doin
print = ...
(?!?!)
As said by Lisa print is a function not a variable
So remove the '=' sign and (' ')
After doing these things, you will surely pass the test cases
0
mahendra nag Why are you taking the bill in as an int? What if the bill was $15.75... It's better to cast it as a float.
And why are you casting the tip amount twice? That doesn't make logical sense. If you're going to take in different tip percentages, just cast it once. You're also missing a ) on that line.
Your print line is also wrong. You're just outputting 'bill*20/100'. It's not actually calculating anything. And why are you taking in the tip percentage if you're not actually using it in the equation? You need to remove the single quotes, or format it with either string format, or f string. So, something like
print('{amount:.2f}'.format(amount = bill * (tip / 100)))
Or
print(f'{bill * (tip / 100)}')
0
Ade Rash You don't need to cast tip to a float in the print, the division operator returns a float. So you can just do print(tip).
- 1
bill = int(input())
tip = float(int(input())
print = ('bill*20/100')
- 2
Please try it and send
- 2
No bro its showing error
- 2
Please help
- 3
Nope u r wrong
- 3
I thought problem was in my code... but the real problem is with this app... my codes worked fine in python...