본문 바로가기

기초언어

(92)
Python 수강 노트 8 - 파이썬 설치 여부 : 윈도우키 + r -> cmd -> python --version- 파이썬은 64bit로 설치(x86-64) windows x86-64 executable installer 항목 다운로드- Add python 3.7 Path 체크 후 설치- 파이썬 실행 명령어 : cmd -> python / cmd -> python 파일명.py / 위치한 폴더 shift 누른상태에서 오른쪽 버튼 -> 여기에 PowerShell 창 열기 -> python 파일이름- IDE : 코딩,디버그,컴파일,배포 개발에 관련된 모든작업을 하나의 프로그램 안에서 처리하는 소프트웨어- 주석문 : 개발자의 필요 따라 명시하는 설명문 / 프로그램 실행 시 제외됨 / # 주석문- 주석문 여러줄 : ""..
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
Python Learn the basics Quiz 5 Q>[1, 2, 3, 4, 5]라는 리스트를 [5, 4, 3, 2, 1]로 만들어 출력하시오.(리스트의 순서를 뒤집는 함수를 사용해야 합니다.) A>list_num = [1, 2, 3, 4, 5] list_num.reverse() print(list_num) O>[5, 4, 3, 2, 1] Process finished with exit code 0
Python Learn the basics Quiz 4 Q>1. 여행에서 찍은 사진을 C:\python\helloworld.jpg의 경로에 보관하고 있다.2. 이 사진의 파일의 경로를 임의의 변수에 할당하고, 사진이 보관되어 있는 폴더의 위치와 파일이름, 확장자를 출력하는 프로그램을 작성하시오.3. 단, 출력에 있어 rfind 함수와 문자열 슬라이스 기능만을 활용하시오.4. 아래와 같이 출력하시오. C:\myphotohelloworldjpg A1>file_folder = 'C:\python\helloworld.jpg' root = file_folder[:file_folder.rfind('\\')] folder = file_folder[file_folder.rfind('h'):file_folder.rfind('.')] extension = file_folder..
Python Learn the basics Quiz 3 Q>1. 어떤 사람의 주민번호가 870111-2022214일 때, 이 사람의 생년월일을 출력하는 프로그램을 작성하여 소스코드와 실행 결과를 제시하시오.2. 단, 결과를 출력할 때는 문자열의 format 함수를 사용하세요. A>rrn = '870111-2022214' year = rrn[:2] month = rrn[2:4] day = rrn[4:6] print('당신의 생일은 {}년 {}월 {}일 입니다.'.format(year, month, day)) O>당신의 생일은 80년 10월 23일 입니다. Process finished with exit code 0