[Introduction&Theory] Python_basic
[Introduction]
https://nomadcoders.co/courses
All Courses – ๋ ธ๋ง๋ ์ฝ๋ Nomad Coders
์ด๊ธ๋ถํฐ ๊ณ ๊ธ๊น์ง! ๋๊ผฌ์ค๊ณผ ํจ๊ป ํ์คํ์ผ๋ก ์ฑ์ฅํ์ธ์!
nomadcoders.co
The collaborative browser based IDE
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript,
repl.it
https://docs.python.org/3/library/
The Python Standard Library — Python 3.8.5 documentation
The Python Standard Library While The Python Language Reference describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It also describes some of the opt
docs.python.org
[Theory]
1. Data Types of Python
1) Variable(๋ณ์)
์๋ฃํ ์ ์ธ ์ํจ, snake_case ํ๊ธฐ
Class | ์๋ฃํ | ๋น๊ณ |
int | number | ์ ์ |
float | float | ์ค์ |
str | string | ' ๋๋ " ์ฌ์ฉํ์ฌ ํ๊ธฐ |
bool | boolean | True, False(0) (๋๋ฌธ์ ํ๊ธฐ) |
NoneType | none | None์ผ๋ก ํ๊ธฐ (์ผ์ข ์ NULL : ์๋ฌด๊ฒ๋ ์์์ ์ ์ฅ) |
* ์ถ๋ ฅํจ์ : print(var) > java์ ๋ฌ๋ฆฌ '๋ฌธ์์ด+์ซ์' ์๋ ๊ฒฐํฉX > f ํฌ๋ฉง ์ฌ์ฉํ์ฌ ํํ
* ์๋ฃํํ์ธํจ์ : type(var)
2) List in Python : Sequence type
์ด๊ฑฐํ > list, Tuple
(1) List : mutable sequence
- ์์ /์ฐ์ฐ ๊ฐ๋ฅ = common/ mutable sequence operation ๋ ๋ค ์ฌ์ฉ ๊ฐ๋ฅ
- ์ฌ๋ฌ ์๋ฃํ ํ๋ฒ์ ๊ฐ๋ฅ
- ๋๊ดํธ ์ฌ์ฉ : []
(2) tuple : immutable sequence
- ์์ /์ฐ์ฐ ๋ถ๊ฐ๋ฅ = common sequence operation๋ง ์ฌ์ฉ ๊ฐ๋ฅ
- ์๊ดํธ ์ฌ์ฉ : ()
(3) Dictionary
- ์์ /์ฐ์ฐ ๊ฐ๋ฅ
- key์ value๊ฐ์ผ๋ก ๊ตฌ์ฑ
- ํค๋ช ์ ์ธ๋ฑ์ค๋ก ํ์ฉ : ์กฐํ, ์์ฑ ๋ฑ์ ์ฐ์ฐ๊ฐ๋ฅ
- ์ค๊ดํธ ์ฌ์ฉ : {} → { key : value, key : value, ... }
2. Built in Functions
1) function
์ ์ฅํ๊ณ ์ถ์ ํ๋(๊ธฐ๋ฅ)์ ์์ฑ → ์ฌ์ฌ์ฉ์ ์ํจ
https://docs.python.org/3/library/functions.html
Built-in Functions — Python 3.8.5 documentation
Built-in Functions The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order. abs(x) Return the absolute value of a number. The argument may be an integer or a floating po
docs.python.org
2) How to create function?
ํ์ด์ฌ ํจ์๋ define(์ ์)ํ๋ค๋ ํํ ์ฌ์ฉ
๋ธ๋ก์ผ๋ก ํํํ์ง ์์ >> identation(๋ค์ฌ์ฐ๊ธฐ)ํํ ์ฌ์ฉ
argument๋ ์ฒ์์ default๊ฐ ์ค์ ๊ฐ๋ฅ
๋ฐํ์ return์ด์ฉ = ํจ์ํธ์ถ์ return๊ฐ์ผ๋ก ์นํ
3. Conditionals : IF - ELIF - ELSE
์กฐ๊ฑด์ด ์ฐธ์ธ ๊ฒฝ์ฐ ์คํ > ๊ดํธ ๋ฌถ๊ธฐ ์์ > ๋ค์ฌ์ฐ๊ธฐ
4. LOOP : For in
์์๋๋ก ์์ ์ ์ํ๋ ๊ฒฝ์ฐ ์ฌ์ฉ : for x in [list or str]
5. Modules
์ผ์ข ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋๋ ํด๋์ค ๊ธฐ๋ฅ
import ํด๋์ค๋ช
from ํด๋์ค๋ช import ํจ์๋ช (๋ชจ๋๋ช ) [as ๋ณ์นญ] > ์ฌ์ฉํ ํจ์๋ง ๋ถ๋ฌ์ค๋๊ฒ์ ์ถ์ฒํ