코딩/Python
-
[Python tutorial] 4. Data type - Numbers코딩/Python 2022. 12. 21. 17:11
Numbers int float complex Integer: int x = 1 y = 100 z = -300 Float x = 1.10 y = 1.0 z = -35.59 a = 35e3 # scientific numbers with an "e" b = 12E4 c = -87.7e100 Complex x = 3+5j y = 5j z = -5j Type Conversion int(), float(), complex() x = 1 # int y = 2.8 # float z = 1j # complex, 다른 타입으로 변환 불가 a = float(x) # 1.0 b = int(y) # 2 c = complex(x) # (1+0j) Random Number: random() Random module referen..
-
[Python tutorial] 3. Data types코딩/Python 2022. 12. 21. 17:10
Built-in Data Types Text Type: str Numeric Types: int, float, complex Sequence Types: list, tuple, range Mapping Type: dict Set Types: set, frozenset Boolean Type: bool Binary Types: bytes, bytearray, memoryview None Type: NoneType Collections (Arrays) List: ordered, changeable, Allows duplicate members Tuple: ordered, unchangeable, Allows duplicate members Set: unordered, unchangeable(possible ..
-
[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..