강의목표: 데이터타입, 숫자, 연산, 형변환, f-문자열
(Data Type,Numbers, Operations, Type Conversion, f-Strings)
참고자료1 스택오버플로우(소수점이하 2자리까지 숫자를 반올림하는방법)
참고자료2 소수점 이하 2자리에서 반올림하기
1. 가격중에 팁으로 몇%를 더 줄지 정하고, 인원 수에따라 N빵하면 인당 얼마씩 내면되는지 계산하는 프로그램.
If the bill was $150.00, split between 5 people, with 12% tip.
Each person should pay (150.00 / 5) * 1.12 = 33.6
Format the result to 2 decimal places = 33.60
Thus everyone's share of the total bill is $30.00 plus a $3.60 tip.
Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪
Welcome to the tip calculator.
What was the total bill? $124.54
How many people to split the bill? 5
What percentage tip would you like to give? 10, 12, or 15? 12
Each person should pay: $27.9
아직 연산자 모르는상태라 마지막행 구현을 못했음.
total_bill = input("Welcome to the tip caculator.\nWhat was the total bill? ")
people = input("How many people to split the bill? ")
tip_percent = input("What percentage tip would you like to give? 10, 12, or 15? ")
print("Each person should pay: " + (total_bill * (1+tip_percent/100))/5)
#If the bill was $150.00, split between 5 people, with 12% tip.
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Round the result to 2 decimal places.
print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("How much tip would you like to give? 10, 12, or 15? "))
people = int(input("How many people to split the bill?"))
tip_as_percent = tip / 100
total_tip_amount = bill * tip_as_percent
total_bill = bill + total_tip_amount
bill_per_person = total_bill / people
final_amount = round(bill_per_person, 2)
# FAQ: How to round to 2 decimal places?
# Find the answer in the Q&A here: https://www.udemy.com/course/100-days-of-code/learn/lecture/17965132#questions/13315048
print(f"Each person should pay: ${final_amount}")
#유데미 #유데미코리아 #스타트위드유데미 #스터디윗미