Created
November 3, 2021 15:45
-
-
Save dalcon10028/2e5628b45ee7db02232bb3ec90e60afa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# 문제 1 | |
traffic_code = [0, 9, 5] | |
def is_traffic_code(input_value): | |
return 0 <= input_value and input_value <= 2 | |
while True: | |
first = input('첫 번째 교통수단 (코드)를 입력해주세요!') | |
if not is_traffic_code(first): | |
print('교통수단 입력 코드 에러!') | |
break | |
if first == 0: continue | |
cost = first + traffic_code[first] | |
second = input('두 번째 교통수단 (코드)를 입력해주세요!') | |
if not is_traffic_code(second): | |
print('교통수단 입력 코드 에러!') | |
break | |
cost += traffic_code[second] | |
print(cost) | |
# 문제 2 | |
sample_data = [ | |
4, 28, 43, 21, 8, 26, 23, 48, 29, 22, | |
1, 27, 27, 25, 14, 1, 38, 46, 31, 28, | |
42, 35, 44, 26, 37, 17, 8, 1, 39, 48, | |
2, 19, 14, 41, 31, 40, 11, 30, 48, 23, | |
0, 10, 25, 47, 32, 19, 40, 8, 19, 45 | |
] | |
while True: | |
multiple = input('배수를 입력해주세요!') | |
if multiple == 0: | |
print('배수 입력 에러!') | |
break | |
result = sum(sample_data[multiple-1::multiple]) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment