[*]Если счет составлял 150 долларов США, разделите его между 5 человеками и получите чаевые в размере 12 %.[*]Каждый человек должен заплатить (150,00 / 5) * 1,12 = 33,6
[*]Отформатируйте результат до 2 десятичных знаков = 33,60
Код: Выделить всё
bill = input("What is the total bill?")
# bill is 150.00
tip = input("What percentage tip would you like to give? 10, 12, or 15?")
# tip will be 12%
max_tip = float(tip) / 100
# split between 5 people
people = input("How many people to split the bill?")
max_split = int(bill) / int(people)
max_cost = int(max_split) * float(max_tip)
print(f"Each person should pay:{max_cost}")
Код: Выделить всё
What is the total bill?150
What percentage tip would you like to give? 10, 12, or 15?12
How many people to split the bill?5
Each person should pay:3.5999999999999996
Код: Выделить всё
float(max_tip, 2)
Код: Выделить всё
line 77, in
max_cost = int(max_split) * float(max_tip, 2)
TypeError: float expected at most 1 argument, got 2
Process finished with exit code 1
А также, как превратить 12% в 1,12?
Подробнее здесь: https://stackoverflow.com/questions/768 ... calculator