Python
-
Excercise 2(enumerate(), zip(), for문, while문 활용)Python 2023. 3. 26. 13:59
1. 자료 구조 심화 다음의 (과일이름, 과일개수) 튜플로 구성된 리스트를 활용하여 다음의 문항을 해결하세요 In [ ]: import numpy as np fruit = [('apple', np.random.randint(1,11)), ('banana', np.random.randint(1,11)), ('cherry', np.random.randint(1,11)), ('grape', np.random.randint(1,11)), ('orange', np.random.randint(1,11)), ('strawberry', np.random.randint(1,11)), ('melon', np.random.randint(1,11))] 문항1] fruit 리스트의 홀수번째 인덱스의 튜플만을 담은 fruit02..
-
Excercise 1(자료구조, 리스트 활용하기)Python 2023. 3. 26. 13:55
1. 거스름돈을 알려주는 프로그램 사용자가 물건의 가격과 지불한 금액을 입력 물건 가격과 지불한 금액은 100원 단위 거스름돈을 계산해주되 동전의 개수는 최대한 적게 거스름돈은 500원, 100원짜리로만 계산 In [ ]: price = int(input('물건의 가격을 입력하세요:')) pay = int(input('지불한 금액을 입력하세요:')) change = pay-price change_500 = change // 500 change_100 = (change-(500*change_500)) // 100 print('거스름돈은 총', change, '원입니다.') print('500원', change_500, '개 100원', change_100, '개 입니다') 거스름돈은 총 3000 원입니다...