Python
-
[Python tutorial] 2. Basic, Variables, Module, User input코딩/Python 2022. 12. 21. 17:10
Basic grammer Indentation if 5 > 2: print("Five is greater than two!") # Five is greater than two! if 5 > 2: print("Five is greater than two!") if 5 > 2: print("Five is greater than two!") Comments # This is a comment. """ This is a comment written in more than just one line """ Variables 문자 또는 _로 시작 숫자로 시작할 수 없음 알파벳, 숫자, _만 사용 대소문자 구분 Creating Variables x = 5 # int y = "Apple" # str a, b, c = "..
-
[Python tutorial] 1. Introduction코딩/Python 2022. 12. 21. 17:10
Python, Guido van Rossum, 1991 사용목적 웹 개발(서버 측) 소프트웨어 개발 수학 시스템 스크립팅 파이썬은 무엇을 할 수 있나요? 서버에서 웹 애플리케이션을 생성. 소프트웨어와 함께 워크플로를 생성. 데이터베이스 시스템에 연결. 파일을 읽고 수정. 빅 데이터를 처리하고 복잡한 수학을 수행. 신속한 프로토타이핑 또는 생산 준비가 된 소프트웨어 개발용. 왜 파이썬인가? 다양한 플랫폼(Windows, Mac, Linux, Raspberry Pi 등)에서 작동. 영어와 유사한 간단한 구문 다른 프로그래밍 언어보다 적은 줄로 프로그램을 작성. 인터프리터 시스템에서 실행되므로 코드가 작성되자마자 실행. 이는 프로토타이핑이 매우 빠를 수 있음을 의미. 절차적 방식, 객체지향적 방식 또는 기능적..
-
[Python] 모듈 Module과 __main__코딩/Python 2022. 12. 20. 23:29
Module Import module & namespace 모듈: 외부에서 임포트해서 쓰는 라이브러리 같은 함수들의 컬렉션 외부 모듈을 임포트할 때 파이썬은 모듈의 함수들을 직접 가지고 오지 않고 모듈 이름만 현재의 'namespace'에 추가 이 모듈의 이름은 전역변수 __name__ 에 저장 모듈의 함수는 모듈이름.함수()로 호출. 자주 쓰는 함수는 다른 이름으로 대입해서 사용. # 외부 모듈 my_func.py def func_a(): print(a) def func_b(): print(b) import my_func my_func.func_a() my_func.func_b() func_c = my_func.func_a func_c() 각 모듈에는 정의된 모든 함수들에 의해 전역 namespace로..
-
[Python/Turtle] 7. Help and configuration, Turtledemo코딩/Python 2022. 12. 20. 01:22
Help and configuration How to use help Screen 및 Turtle 클래스의 공개 메서드는 docstring을 통해 광범위하게 문서화. 따라서 Python 도움말 기능을 통해 온라인 도움말로 사용. IDLE을 사용하는 경우 툴팁에 함수/메서드 호출에 입력된 docstring의 서명과 첫 번째 줄이 표시. 메서드 또는 함수에서 help()를 호출하면 docstring이 표시. help(Screen.bgcolor) Help on method bgcolor in module turtle: bgcolor(self, *args) unbound turtle.Screen method Set or return backgroundcolor of the TurtleScreen. Argumen..
-
[Python/Turtle] 6. Public classes코딩/Python 2022. 12. 20. 01:20
빨리가기 RawTurtle / Turtle / TurtleScreen / Screen / ScrolledCanvas / Shape / addcomponent / Vec2D Public classes class turtle.RawTurtle(canvas) / class turtle.RawPen(canvas) canvas – a tkinter.Canvas, a ScrolledCanvas or a TurtleScreen 거북이를 만든다. 거북이는 위에서 "Turtle/RawTurtle의 메서드"로 설명한 모든 메서드를 가지고 있다. class turtle.Turtle RawTurtle의 하위 클래스는 동일한 인터페이스를 갖지만 처음 필요할 때 자동으로 생성된 기본 Screen 개체를 그린다. class tur..
-
[Python/Turtle] 5. Methods of TurtleScreen/Screen and corresponding functions코딩/Python 2022. 12. 20. 01:18
bgcolor / bgpic / clear / clearscreen / reset / resetscreen / screensize / setworldcoordinates / delay / tracer / update / listen / onkey / onkeypress / onclick / ontimer / mainloop / textinput / numinput / mode / colormode / getcanvas / getshapes / register_shape / turtles / window_height / window_width / bye / exitonclick / setup / title Methods of TurtleScreen/Screen and corresponding functio..
-
[Python/Turtle] 4. Methods/Color control, Filling코딩/Python 2022. 12. 19. 21:55
빨리가기 pencolor() / fillcolor() / color() / filling() / begin_fill() / end_fill() Methods of RawTurtle/Turtle Color control turtle.pencolor(*args) 펜 색상을 반환하거나 설정 입력 포맷 pencolor() 현재 펜 색상을 색상 지정 문자열 또는 튜플로 반환 다른 color/pencolor/fillcolor 호출에 대한 입력으로 사용 pencolor(colorstring) pencolor를 "red", "yellow" 또는 "#33cc8c"와 같은 Tk 색상 사양 문자열인 colorstring으로 설정 pencolor((r, g, b)) pencolor를 r, g, b의 튜플로 표현되는 RGB 색..
-
[Python/Turtle] 3. Methods/Turtle state & Settings for measurement코딩/Python 2022. 12. 19. 21:36
빨리가기 position() / towards() / xcor() / ycor() / heading() / distance() / degrees() / radians() Methods of RawTurtle/Turtle Turtle's state turtle.position() / turtle.pos() 거북이의 현재 위치를 (x,y) (Vec2D vector)로 반환. turtle.pos() (440.00,-0.00)turtle.towards(x, y=None) x – a number or a pair/vector of numbers or a turtle instance y – a number if x is a number, else None 거북이 위치에서 (x,y)로 지정된 위치까지의 선, ..