20160126_python
TRANSCRIPT
![Page 1: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/1.jpg)
BY. PNY
경희대학교 컴퓨터공학과
ICNS 연구실
2016. 01. 26
박나연
![Page 2: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/2.jpg)
BY. PNY
01 파이썬이란?
02 파이썬 문법
03 파이썬으로 뭘 할까?
04 파이썬 스터디
2
![Page 3: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/3.jpg)
BY. PNY
3
![Page 4: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/4.jpg)
BY. PNY
python [명] 비단뱀4
![Page 5: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/5.jpg)
BY. PNY
https://www.python.org/
전 세계에서 5번째로 많이 사용되는 언어(2016년 1월 TIOBE 사 통계 자료)
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 5
![Page 6: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/6.jpg)
BY. PNY
귀도 반 로섬(Guido van Rossum)이 심심해서 제작
1991년 발표
객체 지향 언어
평소 좋아한 코미디에서 따옴 ▶
https://ko.wikipedia.org/wiki/파이썬 6
![Page 7: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/7.jpg)
BY. PNY
7
“ 하나이상의해결법이 존재한다 ”
“가장아름다운하나의답이 존재한다 ”
Beautiful is better than ugly
Explicit is better than implicit
Simple is better than complex
![Page 8: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/8.jpg)
BY. PNY
인간다운 언어
많은 Platform 지원오픈소스
객체 지향 언어…
많은 Library 지원
8
![Page 9: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/9.jpg)
BY. PNY
높은 생산성!
“ Life is too short, You need Python. ”
9
![Page 10: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/10.jpg)
BY. PNY
생산성
투입된 자원에 비해 산출된 생산량이
어느 정도인가를 대변하는 척도
시사상식사전
[ Productivity ]
http://terms.naver.com/entry.nhn?docId=69139&cid=43667&categoryId=43667 10
![Page 11: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/11.jpg)
BY. PNY
프로그래밍 문법이
사용하기 쉽거나 (Writability)
이해하기 쉬움 (Readability)높은 생산성
11
![Page 12: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/12.jpg)
BY. PNY
* python 2.7 기준 (현재 3.X 까지 나와있으나 대부분 2.7 사용)
12
![Page 13: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/13.jpg)
BY. PNY
a = 1
b = "hello"
print type(a)
print type(b)
<type ‘int’>
<type ‘str’>
javascript 등과 같은 Dynamic Typing
13
![Page 14: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/14.jpg)
BY. PNY
if 4 in [1, 2, 3, 4] :
print “There is 4”
→ “ 만약 4가 [1, 2, 3, 4]안에 있다면 “There is 4”를 출력해라. ”
영어 문장을 읽는 듯한 착각!
14
![Page 15: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/15.jpg)
BY. PNY
for (int i=1; i<4; i++)
cout << i << endl;
for i in range(1, 4):
print i
C++
Python
15
![Page 16: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/16.jpg)
BY. PNY
for i in range(1, 4):
print i
print “Wow”;
print “Fantastic Baby”
‘ { } ’가 아닌 들여쓰기로 범위(scope) 구분
세미콜론(;) 사용은 자유 한 라인에 쓸 경우 : 세미콜론 필요
16
print “Wow”; print “Fantastic Baby”
![Page 17: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/17.jpg)
BY. PNY
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello world!");
}
}
print “Hello world!”
Java
Python
17
![Page 18: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/18.jpg)
BY. PNY
public class Employee
{
private String myEmployeeName;
private int myTaxDeductions = 1;
private String myMaritalStatus = "single";
//--------- constructor #1 -------------
public Employee(String employeeName)
{
this(employeeName, 1);
}
//--------- constructor #2 -------------
public Employee(String employeeName, int taxDeductions)
{
this(employeeName, taxDeductions, “single”);
}
//--------- constructor #3 -------------
public Employee(String employeeName,
int taxDeductions,
String maritalStatus)
{
this.myEmployeeName = employeeName;
this.myTaxDeductions = taxDeductions;
this.myMaritalStatus = maritalStatus;
}
...
class Employee():
def __init__(self
, employeeName
, taxDeductions = 1
, maritalStatus = "single"
):
self.employeeName = employeeName
self.taxDeductions = taxDeductions
self.maritalStatus = maritalStatus
...
Java Python
# 참고# 한줄 주석“““
여러줄 주석”””
# 생성자 __init__
# 소멸자 __del__
18
![Page 19: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/19.jpg)
BY. PNY
숫자형 (Number)
문자열 (String)
리스트 (List)
튜플 (Tuple)
딕셔너리 (Dictionary)
집합 (Sets)
참과 거짓 (True & False)
변수 (Variable)
19
![Page 20: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/20.jpg)
BY. PNY
숫자형 (Number)
문자열 (String)
리스트 (List)
튜플 (Tuple)
딕셔너리 (Dictionary)
집합 (Sets)
참과 거짓 (True & False)
변수 (Variable)
20
![Page 21: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/21.jpg)
BY. PNY
t1 = ()
t2 = (1, ) #한 개의 요소만을 넣을 때 ,필요t3 = (1, 2, 3)
t4 = 1, 2, 3 #괄호 생략 가능t5 = ('a', 'b', ('ab', 'cd'))
리스트의 [ 와 ] 대신 튜플은 ( 와 )로 둘러싼다 리스트는 그 값을 생성, 삭제, 수정이 가능하지만
튜플은 그 값을 변화시킬 수 없다. 이외에는 리스트와 동일
21
![Page 22: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/22.jpg)
BY. PNY
# {Key1:Value1, Key2:Value2, Key3:Value3 ...}
dic = {'name':'pey', 'phone':'0119993323',
'birth': '1118'}
key, value의 형태 (흔히 아는 Hash의 개념)
key를 통해 value를 얻을 수 있다.
중복 key 사용은 자제 (나머지가 무시됨)
key에는 리스트는 사용할 수 없지만 튜플은 가능하다.(변하지 않는 값이기 때문)
22
![Page 23: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/23.jpg)
BY. PNY
s1 = set([1, 2, 3])
s2 = set(“Hello”)
print s1
print s2
집합에 관련된 것들을 처리하기에 좋음(교집합, 합집합, 차집합 등 지원)
중복을 허용하지 않는다.
순서가 없다. (indexing 불가)23
set([1, 2, 3])
set([‘H’, ‘e’, ‘l’, ‘o’])
![Page 24: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/24.jpg)
BY. PNY
24
![Page 25: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/25.jpg)
BY. PNY
시스템 유틸리티
운영체제(Windows, Linux 등)의 시스템 명령어들 지원
갖가지 시스템 관련 유틸리티 프로그램 제작이 쉬움
25
![Page 26: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/26.jpg)
BY. PNY
GUI 프로그램
다른 언어보다 GUI 프로그래밍이 쉬운 편
파이썬과 함께 제공되는 Tkinter나 외부 라이브러리인 PyQT, PyGTK등
26
![Page 27: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/27.jpg)
BY. PNY
GUI 프로그램 : Tkinter
27
![Page 28: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/28.jpg)
BY. PNY
C/C++와의 결합
파이썬은 C 언어를 바탕으로 제작 모듈을 사용하면 파이썬 → C에서 사용 / C → 파이썬에서 사용 가능
부족한 부분을 C/C++로 작성한 후 파이썬 프로그램과 결합
28
![Page 29: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/29.jpg)
BY. PNY
웹 / DB 프로그래밍
Django, Flask 등의 웹 프레임워크를 이용하여 웹 제작
Sybase, Infomix, Oracle, MySQL 등 DB 접근 도구 제공
29
![Page 30: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/30.jpg)
BY. PNY
높은 성능을 요구하거나하드웨어를 제어하는
프로그램
많은 반복과 연산을
필요로 하는 프로그램
데이터 압축
프로그램
30
![Page 31: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/31.jpg)
BY. PNY
31
![Page 32: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/32.jpg)
BY. PNY
RETURN에서 진행한속성 Python Game Study
2016년 1월 6, 7, 8, 11, 12일 - 총 5일
32
![Page 33: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/33.jpg)
BY. PNY
1일차 : python 문법 공부 & 숫자 야구 게임
2일차 : 똥 피하기 게임
3일차 : 슈팅 게임(형식은 자유)
4~5일차 : 자유 주제
33
![Page 34: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/34.jpg)
BY. PNY
코드 아카데미(ko) - pythonhttps://www.codecademy.com/ko/tracks/python-ko
34
![Page 35: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/35.jpg)
BY. PNY
35
http://www.pygame.org/
python 게임 라이브러리
2000년 출시
안드로이드 지원(ios 미지원)
# 1 - pygame 라이브러리를 임포트 한다.
import pygame
from pygame.locals import *
# 2 - 게임을 초기화한다.
pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))
# 3 - 이미지를 불러온다.
player =
pygame.image.load("resources/images/dude.png")
# 4 - 무한 루프while 1:
# 5 - 화면 그릴 준비. 화면을 검게 만든다.
screen.fill(0)
# 6 - 플레이어를 (100, 100)에 그린다.
screen.blit(player, (100, 100))
# 7 - 화면을 업데이트한다.
pygame.display.update()
# 8 - 발생한 이벤트들을 가져와 처리하는 루프for event in pygame.event.get():
# x 버튼을 클릭하여 종료하려고 하면if event.type==pygame.QUIT:
# pygame 라이브러리 종료 후 프로그램 종료pygame.quit()
exit(0)
https://en.wikipedia.org/wiki/Pygamehttp://www.raywenderlich.com/24252/beginning-game-programming-for-teens-with-python?utm_content=bufferfd9c0&utm_source=buffer&utm_medium=twitter&utm_campaign=Buffer
![Page 36: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/36.jpg)
BY. PNY
36
http://www.sublimetext.com/3
용량, 실행 면에서 가벼운 Code editor
화면 분할, 파일 이동, 명령어 단축키, Packaging 시스템 지원 등
http://cafe.naver.com/webstandardproject/3917
![Page 37: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/37.jpg)
BY. PNY
37
Shooting Game
![Page 38: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/38.jpg)
BY. PNY
WikiDocs – 점프 투 파이썬 (https://wikidocs.net/book/1)
경희대학교 컴퓨터공학과 컨퍼런스 1회 Softcon
- “파이썬 웹 프레임워크 개발 경험 공유” N.E.T 14 방신우
(http://www.slideshare.net/sinwoobang/ss-55115545/1)
Java Vs Python (http://likelink.co.kr/26267)
Java Vs Python (2)
(https://pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-
side-by-side-comparison/)
네이버 D2 – 메일 서비스 파이썬 적용 경험 (http://d2.naver.com/helloworld/1114)
나무위키 – Python (https://namu.wiki/w/Python)
38
![Page 39: 20160126_python](https://reader035.vdocuments.net/reader035/viewer/2022062600/58ec90d11a28ab68508b466f/html5/thumbnails/39.jpg)
BY. PNY
39