형식화된 출력
Coddy Python 여정의 기초 섹션에 포함된 레슨. 77개 중 34번째.
챌린지
초급이 프로젝트의 마지막 단계는 출력을 형식에 맞게 지정하는 것입니다!
예를 들어, 다음 입력의 경우:
100 #bill
5 #tip percent
2 #number of people다음 형식으로 출력하세요:
Bill Split Calculator
Total (including tip): $105.0
Each person pays: $52.5중요한 형식 지정 참고 사항:
- 대문자와 기호를 포함하여 표시된 내용과 정확히 같아야 합니다
- 숫자를 반올림하지 마세요 - Python의 기본 float 형식 지정을 사용하세요(.2f 등은 사용하지 마세요)
- 숫자를 float 형식으로 변환하면 Python은 소수점 이하 자릿수가 다르게 표시됩니다(예: 105.0, 52.5, 164.28571428571428)
- 계산한 값을 직접 삽입하려면 f-string을 사용하세요:
f"${variable_name}"
직접 해보기
print("Bill Split Calculator")
bill_amount = float(input())
tip_percentage = float(input())
num_people = int(input())
tip_amount = (tip_percentage / 100) * bill_amount
total_amount = bill_amount + tip_amount
amount_per_person = total_amount / num_people
print(total_amount)
print(amount_per_person)기초의 모든 레슨
직접 연습해 보세요: 온라인 Python 컴파일러