본문 바로가기

기초언어

(92)
Python - 사용자에게 입력 받아 * 산 모양 알고리즘 Q>사용자에게 입력 받아 * 산 모양 만들기 A>star = int(input('*의 높이를 입력하세요 : ')) for i in range(star): for j in reversed(range(star)): if j > i: print(' ', end='') else: print('*', end='') for j in range(star): if j *의 높이를 입력하세요 : 5 * *** ***** **************** Process finished with exit code 0
Python - 계단식 * 출력 알고리즘 Q>계단식 * 출력 알고리즘 A>for i in range(5): for j in range(5): if j *************** Process finished with exit code 0
Python - 5 x 5 사각형 * 출력 알고리즘 Q>5 x 5 사각형 * 출력 알고리즘 A>for i in range(5): for j in range(5): print('*', end='') print() O>************************* Process finished with exit code 0
Python - 기본 * 출력 알고리즘 Q> 기본 * 출력 알고리즘 A>for i in range(5): for j in range(5): if j == i: print('*', end = '') print() O>***** 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..