본문 바로가기

Python_Matter/Solve

(117)
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][..
Python Learn the basics Quiz 8 Q>어느 학생이 일주일간 공부한 시간을 기록한 표이다.일요일이 0이고 토요일이 6을 의미한다고 할 때이 학생이 공부한 시간을 튜플로 표현하여 출력하시오.일 : 7 / 월 : 5 / 화 : 5 / 수 : 5 / 목 : 5 / 금 : 10 / 토 : 7 A>study_day = (0, 1, 2, 3, 4, 5, 6) study_hour = (7, 5, 5, 5, 5, 10, 7) print(study_day[0], study_hour[0]) print(study_day[1], study_hour[1]) print(study_day[2], study_hour[2]) print(study_day[3], study_hour[3]) print(study_day[4], study_hour[4]) print(study..
Python Learn the basics Quiz 7 Q>(1, 2, 3)이라는 튜플에 (4, 5)라는 값을 추가하여 (1, 2, 3, 4, 5)로 구성된 새로운 튜플을 만들어 출력하시오. A>tuple_1 = (1, 2, 3) tuple_2 = (4, 5) print(tuple_1 + tuple_2) O>(1, 2, 3, 4, 5) Process finished with exit code 0
Python Learn the basics Quiz 6 Q>1. ['Life', 'is', 'too', 'short']라는 리스트를 'Life is too short'라는 문자열로 결합하시오.2. 결합된 문자열의 모든 글자를 대문자 형태로 출력하시오. A>list_str = ['Life', 'is', 'too', 'short'] print(' '.join(list_str)) print(' '.join(list_str).upper()) O>Life is too shortLIFE IS TOO SHORT Process finished with exit code 0