Created
April 19, 2023 12:47
-
-
Save junhg0211/79a05611f00d46f25000a269f467c37f to your computer and use it in GitHub Desktop.
돈을 시간으로 바꿔주는 프로그램
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
최저시급을 1달로 하여, 금액을 입력받았을 때에 | |
해당 금액에 대한 최저시급-환산 가치를 출력하는 프로그램. | |
`MONTH`에 저장된 값이 1개월 최저시급이다. | |
""" | |
MONTH = 2010580 | |
def format_time(amount: int): | |
months = amount / MONTH | |
months, days = int(months), months % 1 * 30 | |
days, hours = int(days), days % 1 * 24 | |
hours, minutes = int(hours), hours % 1 * 60 | |
minutes, seconds = int(minutes), minutes % 1 * 60 | |
maybe_years = '' | |
if months > 20: | |
maybe_years = f'({months // 12}년 {months % 12}개월)' | |
return f'{months:,}개월{maybe_years} {days}일 ' \ | |
+ f'{hours}시간 {minutes}분 {seconds:.2f}초' | |
def main(): | |
amount = float(input('가격을 입력하세요: ')) | |
print(f'{int(amount):,}원은 시간 {format_time(amount)}에 해당하는 금액입니다.') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment