목록Python (17)
Jun's Blog

1. 파일에 저장하기print('파일에 기록합니다.')filename = 'mem.txt'myfile01 = open(file='mem.txt', mode='wt', encoding='UTF-8')print(type(myfile01))# mem.txt 파일에 기록members = ['홍영식','김민수','박진철','강호숙']for man in members: message = f'\'{man}\'님 안녕하세요.\n' myfile01.write(message)# end formyfile01.close()print(f'{filename} 파일이 생성됨') print('기존 파일에 내용을 추가합니다.') # at = append textmyfile02 = open(file=filename, ..

1. 함수 선언하여 사용해보기# def는 define의 줄임말# def 함수이름(매개변수01 = [기본값], 매개변수02, ...):def add(first, second): # 함수 정의 return first + second# end defsu01 = 14su02 = 5# positional argument : index 기반 매개 변수 전달 방식result = add(su01, su02)print('%d + %d = %d' % (su01, su02, result))print('%d + %d = %d' % (100, 200, add(100, 200))) su01 = 111su02 = 222# keyword argument : 키워드 기반으로 매개 변수 전달 방식result = add(secon..

1. Comprehension문을 활용하여 배열 생성해보기(for문과 유사함)mylist01 = [idx for idx in range(1, 5)]print(mylist01)mylist02 = [idx * 10 for idx in range(1, 6)]print(mylist02) # 1, 4, 7, ..., 100mylist03 = [idx for idx in range(1, 101, 3)]print(mylist03)# 10의 배수들만 필터링mylist04 = [idx for idx in range(1, 101, 3) if idx % 10 == 0]print(mylist04) 문제 1 : 다음 점수 중에서 몇 명이 합격했는지 출력해 보세요.exam_jumsu = [75, 30, 85, 50] # 합격..

1. List 활용해 보기# coffees = [] # List()를 의미함.coffees = list()coffees.append('아메리카노')coffees.append('콜드브루')coffees.append('카푸치노')coffees.append('바닐라라떼')coffees.append('디카페인커피')coffees.append('카페라떼')coffees.append('카푸치노')# 인덱싱print('앞에서 2번째 음료 : %s' % (coffees[2]))print('뒤에서 1번째 음료 : %s' % (coffees[-1]))# 슬라이싱print('1번째부터 3번째까지 음료 : %s' % (coffees[1:4]))print('3번째부터 끝까지 음료 : %s' % (coffees[3:]))prin..

1. 간단한 산술식 또는 출력 기능 사용해보기 print('이름 입력 : ', end = '') # end = '' 옵션은 엔터키를 누르지 않는다name = input()print('이름 : %s' % (name)) print('이름 입력 : ', end = '') # end = '' 옵션은 엔터키를 누르지 않는다name = input()print('이름 : %s' % (name))print('나이 입력 : ', end = '')age = input()print('이름 : %s' % (name))print('나이 : %d' % (age)) print('이름 입력 : ', end = '') # end = '' 옵션은 엔터키를 누르지 않는다name = input()print('이름 : %s' % (n..

1. 기본 파이썬 패키지 및 파일 생성하기 1.1 파일 생성하기 2. 라이브러리 설치하기설치는 cmd 창에서 명령어를 통해 설치하는 것을 권고합니다. UI를 통해 진행할 경우, 일부 오류나 버그가 발생할 수 있습니다.2.1 cmd 창에서 설치하기cd c:\Python311\Scriptspip install pandasC:\Python311\python.exe -m pip install --upgrade pip# 목록 조회pip list # 시각화를 위한 라이브러리pip install matplotlib pip install seaborn# 파이썬 웹 애플리케이션관련 라이브러리pip install jupyter # html/xml 등에서 데이터를 읽어 오기 위한 라이브러리pip install beautif..

1. Python 설치https://www.python.org/downloads/release/python-3110/ Python Release Python 3.11.0The official home of the Python Programming Languagewww.python.org 2. Pycharm 설치https://www.jetbrains.com/pycharm/ PyCharm: the Python IDE for data science and web developmentThe Python IDE for data science and web development with intelligent code completion, on-the-fly error checking, quick-fixes, a..