day 2-8 Python (팁 계산기 tip-Calculator)
2023. 2. 21. 20:05ㆍ개인적인 공부/Python
팁 계산기 만들기
조건
#If the bill was $150.00, split between 5 people, with 12% tip.
#밥값 150달러, 5명으로 더치페이 12% 팁과 함께
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60 (소수 둘째자리까지 표시)
#Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪
#(2가지 방법이 있다 구글링 해라)
#Write your code below this line 👇
나의 값
print("팁 계산기를 이용해 주셔서 감사합니다.")
bill = float(input("총 지불할 금액은? $"))
tip_percent = float(input("팁은 어느정도 생각하세요? 10, 12 또는 15? ")) * float(1/100)
split_people = float(input("같이 식사를 즐긴 인원은 몇명이세요? "))
pay_per_person = round((bill/split_people)+((bill/split_people)*tip_percent), 2)
result = "{:.2f}".format(pay_per_person) #소수점 두번째 자리가 0이어도 보이게 하기
print(f"각 인원당 지불 하실 금액은: ${result}")
'개인적인 공부 > Python' 카테고리의 다른 글
day 3-2 python (Odd or Even Exercise)(홀수 또는 짝수) (0) | 2023.02.22 |
---|---|
day 3-1 python (if/else 및 조건 연산자를 통한 흐름 제어) (0) | 2023.02.21 |
day 2-7 python (Life in Weeks Exercise) (0) | 2023.02.21 |
day2-6 python (숫자 처리 및 F-String) (0) | 2023.02.21 |
day 2-5 python (BMI example) (0) | 2023.02.21 |