본문 바로가기

Python_Matter

(328)
Python Learn the basics Quiz 16 Q>일 월 화 수 목 금 토 7 5 5 5 5 10 7 위에 근무 시간 일지를 참조하여 급여 계산을 하시오.(일 ~ 수 시간당 4,500원 / 목 ~ 토 시간당 5,200) A>times = [7, 5, 5, 5, 5, 10, 7] total = 0 for i in range(0, len(times)): r = 0 if i >= 3: r += 5200 cash = r * times.pop() total += cash else: r += 4500 cash = r * times.pop() total += cash result = ('일주일간의 총 급여는 {0}원 입니다.'.format(total)) print(result) O>일주일간의 총 급여는 213400원 입니다. Process finished wit..
Python Learn the basics Quiz 15 Q>***************을 출력 하는 프로그램을 작성하시오. A1>for i in range(0, 5): star = "" for j in range(5, i, -1): star += "*" print(star) A2>for i in range(0, 5): for j in range(5, i, -1): if j > i: print('*', end = '') print() O1>*************** Process finished with exit code 0 O2>*************** Process finished with exit code 0
Python Learn the basics Quiz 14 Q>1 ~ 100까지의 자연수 중 3과 5의 공배수를 출력하면서 그에 대한 총합을 구하시오. A>sum = 0 for i in range(1, 101): if i % 3 == 0 and i % 5 == 0: sum += i print(i) result = ("공배수의 총 합 : {0}".format(sum)) print(result) O>153045607590공배수의 총 합 : 315 Process finished with exit code 0
Python Learn the basics Quiz 13 Q>1. 아래와 같은 인벤토리가 있다. 가격 개수 500 291 320 586 100 460 120 558 92 18 30 72 2. 위에 인벤토리에 총 합을 구하시오.3. 판매 금액은 가격에 90%만 받을수 있다. A>inven = {'item1':500, 'item2':320, 'item3':100, 'item4':120, 'item5':92, 'item6':30} inven_count = {'count1':291, 'count2':586, 'count3':460, 'count4':558, 'count5':18, 'count6':72} result_list1 = [] result_list2 = [] for v1 in inven.values(): a = result_list1.append(v1) for..
Python Learn the basics Quiz 12 Q>장바구니 내역을 딕셔너리에 원소로 갖는 리스트로 정의하고 합계금액 / 총 금액을 출력하시오.장바구니 내역 : 38000원 6개 / 20000원 4개 / 17900원 3개 / 17900원 5개 A>price_dic = {'price1':38000, 'price2':20000, 'price3':17900, 'price4':17900} count_dic = {'qty1':6, 'qty2':4, 'qty3':3, 'qty4':5} result_list1 = [] result_list2 = [] for v1 in price_dic.values(): a = result_list1.append(v1) for v2 in count_dic.values(): b = result_list2.append(v2) count..
Python Learn the basics Quiz 11 Q>1. 리스트 [True, False, False, True, False] 가 있다.2. 위에 리스트 내용을 반전 시키는 프로그램을 작성하시오. A>check_list = [True, False, False, True, False] print(check_list) boolean_list = [] for i in check_list: if i == True: boolean_list.append(False) else: boolean_list.append(True) print(boolean_list) O>[True, False, False, True, False][False, True, True, False, True] Process finished with exit code 0
Python Learn the basics Quiz 10 Q>BMI 프로그램을 구현하시오.1. 사용자에게 키와 몸무게를 입력 받으시오.2. BMI 수치는 20%이하 - 정상(안심)20%초과, 30%이하 - 경도비만(주의)30%초과, 50%이하 - 중등도 비만(위험)50%초과 - 고도비만(매우위험)3. BMI 수치에 따라 출력을 하시오. A>height = int(input('키를 입력하세요 : ')) weight = int(input('몸무게를 입력하세요 : ')) BMI = weight / (height * height / 10000) if BMI < 20: print("정상(안심)") elif BMI < 30: print("경도 비만(주의)") elif BMI < 50: print("중등도 비만(위험)") else: print("고도 비만(매우 위험") O..
Python Learn the basics Quiz 9 Q>장바구니 내역을 딕셔너리에 원소로 갖는 리스트로 정의하고 합계금액을 출력하시오.장바구니 내역 : 38000원 6개 / 20000원 4개 / 17900원 3개 / 17900원 5개 A>cart = [{'price':38000, 'qty':6}, {'price':20000, 'qty':4}, {'price':17900, 'qty':3}, {'price':17900, 'qty':5}] price = '{0}원 x {1}개 -> 총 {2}원' print(price.format(cart[0]['price'], cart[0]['qty'], cart[0]['price'] * cart[0]['qty'])) print(price.format(cart[1]['price'], cart[1]['qty'], cart[1][..