Tip Calculator (Python 3) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Tip Calculator (Python 3)

Hey, I've been teying to figure out the tip calculator problem. I can't get it, here's my progress so far: ----- bill = int(input()) print(float(bill * 20 // 100)) -----

19th Mar 2021, 8:59 PM
Aron
Aron - avatar
17 Answers
+ 14
#Acts like a vacuum for user to input the bill amount bill = int(input()) x = 20 #tip percentage y = 100 #overrall percentage #calculates the tip amount tip = (bill * int(x))/int(y) print(float(tip))
25th Apr 2021, 9:49 AM
Jackson Kairani Maina
Jackson Kairani Maina - avatar
+ 6
bill=int(input()) tip=float(bill*20/100) print(tip)
1st Oct 2021, 11:18 AM
Sokol Hajri
Sokol Hajri - avatar
+ 4
Answer is bill = int(input()) #your code goes here x = 20 #tip percentage y = 100 #overrall percentage #calculates the tip amount tip = (bill * int(x))/int(y) print(float(tip))
26th Aug 2021, 10:30 PM
Shan Romesh
Shan Romesh - avatar
+ 1
bill = int(input()) x = 20 #tip percentage y = 100 #overrall percentage #calculates the tip amount tip = (bill * int(x))/int(y) print(float(tip))
9th Jul 2021, 4:45 AM
Dhaval Kanjariya
Dhaval Kanjariya - avatar
+ 1
bill = float(input("How much was the meal? ")) fifteen = ((bill / 100) * 15) eightteen = ((bill / 100) * 18) twenty = ((bill / 100) * 20) total1 = (fifteen + bill) total2 = (eightteen + bill) total3 = (twenty + bill) print("\nA 15% tip is
quot;, fifteen) print("With tip your total is
quot;, total1) print("\nAn 18% tip is
quot;, eightteen) print("With tip your total is
quot;, total2) print("\nA 20% tip is
quot;, twenty) print("With tip your total is
quot;, total3)
19th Jul 2021, 5:35 PM
Elias Mahon
Elias Mahon - avatar
0
bill = int(input()) #your code goes here print(float(bill*20/100))
2nd Nov 2021, 3:34 AM
Sandhya.v
Sandhya.v - avatar
0
this is mine bill = int(input()) tip= (bill * 20/100) print (float (tip))
3rd Mar 2022, 1:40 AM
ColeN
ColeN - avatar
0
I did it a shortcut way I did bill=int(input()) Print(bill*0.2) This just gave me 20% of whatever input (kind of cheating) but will now learn what was required
12th May 2022, 8:37 PM
Thomas Willshaw
0
tip = float(int(input())*20/100) print(tip)
13th Jul 2022, 1:44 PM
Sergey Yanko
Sergey Yanko - avatar
0
bill=float (input("Enter your bill:-")) tip=20 time=((bill*tip)/100) print (time)
17th Aug 2022, 3:53 PM
Qusai Mobarak
Qusai Mobarak - avatar
0
# My_code bill = int(input()) #your code goes here tip = float(input()) print(bill * tip//100) #Acts like a vacuum for user to input the bill amount bill = int(input()) x = 20 #tip percentage y = 100 #overrall percentage #calculates the tip amount tip = (bill * int(x))/int(y) print(float(tip)) What is the diffence between the first code and the second one? Because in the code coach it said the fisrt code was wrong and i did not get why?
25th Sep 2022, 9:47 AM
Emmanuel Arthur
0
Can anyone give me the right answer please???
11th Oct 2022, 1:44 PM
Nima Tanchangya
0
Nima Tanchangya please, show your attempt before
11th Oct 2022, 3:29 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
try this, may not be the cleanest but it works. def calculate(): print("Welcome To The Python Tip Calculator") #Prompt the user to enter the amount on the bill meal = float(int(input("What is the total bill?: "))) #Prompt the user for the % tip they'd like to leave tip = int(input("What % tip would you like to give?: ")) #Prompt the user for the # of people splitting the bill people = int(input("How many people are splitting the bill?: ")) tax = .10 print(tax) #figure the tip on the bill amount pre tax tip_amount = meal * tip/100 print(f'Your meal was ${meal} and your tip is ${tip_amount}') #figure the sales tax from the bill amount tax_amount = meal * tax #calculate the total bill to include tax and tip total_cost = tip_amount + tax_amount + meal #update the bill to include the tax print(f' Your total with tax is ${total_cost}') bill_per_person = total_cost / people final_total = bill_per_person #Calculate the amount each person owes based on the bill and tips the user entered print(f'Your total bill is {total_cost} and each person should pay {final_total}') # we need to include an option to continue to calculate for other tip amounts another_amount = input('Would you like to enter another amount? ') print(another_amount) for letter in another_amount: if letter == "n": print('I hope you have enjoyed using your Python Tip Calculator!') return else: another_amount == "y" calculate() calculate()
27th Oct 2022, 11:13 PM
talesa howell
talesa howell - avatar
0
You almost had it, Aron! The real answer is: bill = int(input()) print(float(bill*20/100)) For yours, you used the integer division symbol which is 2 slashes. You need to use the normal division symbol (one slash) for the syntax on this problem to work. Hope this helps!
14th Mar 2023, 4:26 AM
Chase Tunney
Chase Tunney - avatar
- 2
Hello it tried replicating the code but am not prompted to give the input
9th Jul 2021, 11:13 AM
Gemuh Hans
- 4
hi! you use the integer division operator // instead of the normal one /
19th Mar 2021, 9:24 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar