+ 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)) -----
17 Respostas
+ 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))
+ 6
bill=int(input())
tip=float(bill*20/100)
print(tip)
+ 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))
+ 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))
+ 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)
0
bill = int(input())
#your code goes here
print(float(bill*20/100))
0
this is mine
bill = int(input())
tip= (bill * 20/100)
print (float (tip))
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
0
tip = float(int(input())*20/100)
print(tip)
0
bill=float (input("Enter your bill:-"))
tip=20
time=((bill*tip)/100)
print (time)
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?
0
Can anyone give me the right answer please???
0
Nima Tanchangya please, show your attempt before
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()
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!
- 2
Hello it tried replicating the code but am not prompted to give the input
- 4
hi! you use the integer division operator // instead of the normal one /