Skip to content

๐Ÿ 30 Days Of Python

# Day Topics
01 Introduction
02 Variables, Built-in Functions
03 Operators
04 Strings
05 Lists
06 Tuples
07 Sets
08 Dictionaries
09 Conditionals
10 Loops
11 Functions
12 Modules
13 List Comprehension
14 Higher Order Functions
15 Python Type Errors
16 Python Date time
17 Exception Handling
18 Regular Expressions
19 File Handling
20 Python Package Manager
21 Classes and Objects
22 Web Scraping
23 Virtual Environment
24 Statistics
25 Pandas
26 Python web
27 Python with MongoDB
28 API
29 Building API
30 Conclusions

๐Ÿงก๐Ÿงก๐Ÿงก HAPPY CODING ๐Ÿงก๐Ÿงก๐Ÿงก

Support the author to create more educational materials
Paypal Logo

30 Days Of Python: Day 1 - Introduction

Twitter Follow Author: Asabeneh Yetayeh
Second Edition: July, 2021

Day 2 >>

30DaysOfPython

๐Ÿ“˜ Day 1

ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค

_30 days of Python_์— ์ฐธ์—ฌํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ•˜์‹  ๊ฒƒ์„ ์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค. ์ด ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ๋˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ๋ชจ๋“  ๊ฒƒ๊ณผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ์ „์ฒด ๊ฐœ๋…์„ ๋ฐฐ์šฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๊ฐ€ ๋๋‚˜๋ฉด _30DaysOfPython_ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ์„œ๋ฅผ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ฑŒ๋ฆฐ์ง€์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด 30DaysOfPython challenge ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ๊ฐ€์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์†Œ๊ฐœ

Python์€ ๋ฒ”์šฉ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•œ ๊ณ ๊ธ‰ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์˜คํ”ˆ ์†Œ์Šค, ์ธํ„ฐํ”„๋ฆฌํ„ฐ, ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Python์€ ๋„ค๋œ๋ž€๋“œ ํ”„๋กœ๊ทธ๋ž˜๋จธ Guido van Rossum์ด ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์˜ ์ด๋ฆ„์€ ์˜๊ตญ ์Šค์ผ€์น˜ ์ฝ”๋ฏธ๋”” ์‹œ๋ฆฌ์ฆˆ Month Python's Flying Circus ์—์„œ ํŒŒ์ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ๋ฒ„์ „์€ 1991๋…„ 2์›” 20์ผ์— ์ถœ์‹œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ์ฑŒ๋ฆฐ์ง€๋Š” ์ตœ์‹  ๋ฒ„์ „์˜ Python์ธ Python 3๋ฅผ ์ฐจ๊ทผ์ฐจ๊ทผ ๋ฐฐ์šธ ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฃผ์ œ๋Š” 30์ผ๋กœ ๋‚˜๋‰˜๋ฉฐ, ๋งค์ผ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์„ค๋ช…, ์‹ค์ œ ์‚ฌ๋ก€, ๋งŽ์€ ์‹ค์Šต ๋ฐ ํ”„๋กœ์ ํŠธ๊ฐ€ ํฌํ•จ๋œ ์—ฌ๋Ÿฌ ์ฃผ์ œ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.

์ด ์ฑŒ๋ฆฐ์ง€๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ๋ฐฐ์šฐ๊ณ ์ž ํ•˜๋Š” ์ดˆ๋ณด์ž์™€ ์ „๋ฌธ๊ฐ€๋ฅผ ์œ„ํ•ด ๊ณ ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•˜๋Š” ๋ฐ 30~100์ผ์ด ์†Œ์š”๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์ด ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•  ํ™•๋ฅ ์ด ๋†’์Šต๋‹ˆ๋‹ค. ์‹œ๊ฐ์  ํ•™์Šต์ž์ด๊ฑฐ๋‚˜ ๋™์˜์ƒ์„ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ ์ด ์™„์ „ ์ดˆ๋ณด๋ฅผ ์œ„ํ•œ Python ๋™์˜์ƒ์œผ๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์™œ Python์ด๋Š๋ƒ?

์ธ๊ฐ„์˜ ์–ธ์–ด์— ๋งค์šฐ ๊ฐ€๊น๊ณ  ๋ฐฐ์šฐ๊ธฐ ์‰ฝ๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฌ์šด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Python์€ ๋‹ค์–‘ํ•œ ์‚ฐ์—… ๋ฐ ํšŒ์‚ฌ(Google ํฌํ•จ)์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์›น ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ๋ฐ์Šคํฌํ†ฑ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ์‹œ์Šคํ…œ ๊ด€๋ฆฌ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Python์€ ๋ฐ์ดํ„ฐ ๊ณผํ•™ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ์ปค๋ฎค๋‹ˆํ‹ฐ์—์„œ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด Python ํ•™์Šต์„ ์‹œ์ž‘ํ•˜๋„๋ก ์„ค๋“ํ•˜๊ธฐ์— ์ถฉ๋ถ„ํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. Python์€ ์„ธ์ƒ์„ ์ง€๋ฐฐํ•˜๊ณ  ์žˆ์œผ๋‹ˆ ์ง€๋ฐฐ ๋‹นํ•˜๊ธฐ ์ „์— Python์„ ์ง€๋ฐฐํ•˜์‹ญ์‹œ์˜ค.

ํ™˜๊ฒฝ ์„ค์ •

Python ์„ค์น˜

Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด Python์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python์„ ๋‹ค์šด๋กœ๋“œํ•ฉ์‹œ๋‹ค. Windows ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

macOS ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

Windows์—์„œ ์„ค์น˜

Python์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ์žฅ์น˜ ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค.

python --version

Python Version

ํ„ฐ๋ฏธ๋„์—์„œ ๋ณด์‹œ๋‹ค์‹œํ”ผ ์ €๋Š” ํ˜„์žฌ Python 3.7.5 ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ Python ๋ฒ„์ „์€ ๋‚ด ๋ฒ„์ „๊ณผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์ง€๋งŒ 3.6 ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python ๋ฒ„์ „์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ž˜ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์ปดํ“จํ„ฐ์— Python์ด ์„ค์น˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์„น์…˜์œผ๋กœ ๊ณ„์† ์ง„ํ–‰ํ•˜์‹ญ์‹œ์˜ค.

Python ์…ธ

Python์€ ํ•ด์„๋œ ์Šคํฌ๋ฆฝํŒ… ์–ธ์–ด์ด๋ฏ€๋กœ ์ปดํŒŒ์ผํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ํ•œ ์ค„์”ฉ ์‹คํ–‰ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. Python์€ _Python Shell(Python Interactive Shell)_๊ณผ ํ•จ๊ป˜ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ๋‹จ์ผ Python ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

Python Shell์€ ์‚ฌ์šฉ์ž์˜ Python ์ฝ”๋“œ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•˜์—ฌ ๋‹ค์Œ ์ค„์— ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ(cmd)๋ฅผ ์—ด๊ณ  ์“ฐ๊ธฐ:

python

Python Scripting Shell

Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฌ๊ณ  Python ์ฝ”๋“œ(Python ์Šคํฌ๋ฆฝํŠธ)๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ๊ธฐํ˜ธ >>> ์˜†์— Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  Enter๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. Python ์Šคํฌ๋ฆฝํŒ… ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Python script on Python shell

ํ›Œ๋ฅญํ•ฉ๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์–ด๋–ป๊ฒŒ ๋‹ซ์Šต๋‹ˆ๊นŒ? ์…ธ์„ ๋‹ซ์œผ๋ ค๋ฉด ๊ธฐํ˜ธ ์˜†์— >> exit() ๋ช…๋ น์„ ์ž‘์„ฑํ•˜๊ณ  Enter ํ‚ค๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

Exit from python shell

์ด์ œ Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ฌ๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•˜์Šต๋‹ˆ๋‹ค.

Python์€ Python์ด ์ดํ•ดํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ณ ์˜์ ์ธ ์‹ค์ˆ˜๋ฅผ ํ•˜๊ณ  Python์ด ๋ฌด์—‡์„ ๋ฐ˜ํ™˜ํ•˜๋Š”์ง€ ๋ด…์‹œ๋‹ค.

Invalid Syntax Error

๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด Python์€ ์šฐ๋ฆฌ๊ฐ€ ์ €์ง€๋ฅธ ์‹ค์ˆ˜์™€ _Syntax Error: invalid syntax_๋ฅผ ์•Œ๊ณ  ์žˆ์„ ์ •๋„๋กœ ์˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. Python์—์„œ x๋ฅผ ๊ณฑ์…ˆ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ (x)๊ฐ€ Python์—์„œ ์œ ํšจํ•œ ๊ตฌ๋ฌธ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. (x) ๋Œ€์‹  ๊ณฑ์…ˆ์— ๋ณ„ํ‘œ(*)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜๋Š” ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

ํ”„๋กœ๊ทธ๋žจ์—์„œ ์˜ค๋ฅ˜๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์ œ๊ฑฐํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ๋””๋ฒ„๊น…์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. x ๋Œ€์‹  *๋ฅผ ๋„ฃ์–ด ๋””๋ฒ„๊น…ํ•ด ๋ด…์‹œ๋‹ค.

Fixing Syntax Error

๋ฒ„๊ทธ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ๊ณ  ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋˜์—ˆ์œผ๋ฉฐ ์˜ˆ์ƒํ–ˆ๋˜ ๊ฒฐ๊ณผ๋ฅผ ์–ป์—ˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ๋กœ์„œ ๋งค์ผ ์ด๋Ÿฌํ•œ ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๋ฅผ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•์„ ์•„๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋””๋ฒ„๊น…์„ ์ž˜ํ•˜๋ ค๋ฉด ์–ด๋–ค ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์ดํ•ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” Python ์˜ค๋ฅ˜ ์ค‘ ์ผ๋ถ€๋Š” SyntaxError, IndexError, NameError, ModuleNotFoundError, KeyError, ImportError, AttributeError, TypeError, ValueError, ZeroDivisionError ๋“ฑ์ž…๋‹ˆ๋‹ค. ์ดํ›„ ์„น์…˜์—์„œ ๋‹ค๋ฅธ Python ์˜ค๋ฅ˜ ์œ ํ˜•์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋” ์—ฐ์Šตํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋™ํ•˜์—ฌ python์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์”๋‹ˆ๋‹ค.

Python Scripting Shell

Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฝ๋‹ˆ๋‹ค. ๋ช‡ ๊ฐ€์ง€ ๊ธฐ๋ณธ์ ์ธ ์ˆ˜ํ•™ ์—ฐ์‚ฐ(๋”ํ•˜๊ธฐ, ๋นผ๊ธฐ, ๊ณฑํ•˜๊ธฐ, ๋‚˜๋ˆ„๊ธฐ, ๋‚˜๋จธ์ง€, ์ง€์ˆ˜)์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ ์ „์— ๋จผ์ € ๋ช‡ ๊ฐ€์ง€ ์ˆ˜ํ•™์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค:

  • 2 + 3 = 5
  • 3 - 2 = 1
  • 3 * 2 = 6
  • 3 / 2 = 1.5
  • 3 ^ 2 = 3 x 3 = 9

Python์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ถ”๊ฐ€ ์ž‘์—…์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • 3 % 2 = 1 => ๋‚˜๋จธ์ง€๋ฅผ ๊ตฌํ•จ
  • 3 // 2 = 1 => ๋‚˜๋จธ์ง€๋ฅผ ์ œ๊ฑฐ

์œ„์˜ ์ˆ˜ํ•™์‹์„ Python ์ฝ”๋“œ๋กœ ๋ฐ”๊ฟ”๋ด…์‹œ๋‹ค. Python ์…ธ์ด ์—ด๋ ธ์œผ๋ฉฐ ์…ธ ๋งจ ์ฒ˜์Œ์— ์ฃผ์„์„ ์ž‘์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

_comment_๋Š” Python์— ์˜ํ•ด ์‹คํ–‰๋˜์ง€ ์•Š๋Š” ์ฝ”๋“œ์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์ฝ”๋“œ์— ์ผ๋ถ€ ํ…์ŠคํŠธ๋ฅผ ๋‚จ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Python์€ ์ฃผ์„ ๋ถ€๋ถ„์„ ์‹คํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Python์—์„œ ์ฃผ์„์€ ํ•ด์‹œ(#) ๊ธฐํ˜ธ๋กœ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด Python์—์„œ ์ฃผ์„์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค

 # ์ฃผ์„์€ ํ•ด์‹œ๋กœ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
 # (#) ์‹ฌ๋ณผ๋กœ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์€ ํŒŒ์ด์ฌ ์ฃผ์„์ž…๋‹ˆ๋‹ค.

Maths on python shell

๋‹ค์Œ ์„น์…˜์œผ๋กœ ์ด๋™ํ•˜๊ธฐ ์ „์— Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ๋” ๋งŽ์€ ์—ฐ์Šต์„ ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์…ธ์—์„œ _exit()_๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์—ด๋ฆฐ ์…ธ์„ ๋‹ซ์•˜๋‹ค๊ฐ€ ๋‹ค์‹œ ์—ด์–ด Python ์…ธ์—์„œ ํ…์ŠคํŠธ๋ฅผ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์„ ์—ฐ์Šตํ•ด ๋ด…์‹œ๋‹ค.

Writing String on python shell

Visual Studio Code ์„ค์น˜

Python ๋Œ€ํ™”ํ˜• ์…ธ์€ ์ž‘์€ ์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์‹œ๋„ํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•˜๋Š” ๋ฐ ์ ํ•ฉํ•˜์ง€๋งŒ ํฐ ํ”„๋กœ์ ํŠธ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์ž‘์—… ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ์ž๋Š” ๋‹ค์–‘ํ•œ ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Visual Studio Code๋Š” ๋งค์šฐ ์ธ๊ธฐ ์žˆ๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ…์ŠคํŠธ ํŽธ์ง‘๊ธฐ์ž…๋‹ˆ๋‹ค. ๋‚˜๋Š” vscode์˜ ํŒฌ์ด๊ณ  Visual Studio ์ฝ”๋“œ๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•˜๊ณ  ์‹ถ์ง€๋งŒ, ๋‹ค๋ฅธ ํŽธ์ง‘์ž๋ฅผ ์„ ํ˜ธํ•œ๋‹ค๋ฉด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์ž์œ ๋กญ๊ฒŒ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค.

Visual Studio Code

Visual Studio Code๋ฅผ ์„ค์น˜ํ•˜์…จ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋น„๋””์˜ค๋ฅผ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ Python์šฉ Visual Studio Code๋น„๋””์˜ค ์ž์Šต์„œ๋ฅผ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ

Visual Studio ์•„์ด์ฝ˜์„ ๋‘ ๋ฒˆ ํด๋ฆญํ•˜์—ฌ Visual Studio ์ฝ”๋“œ๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ์—ด๋ฉด ์ด๋Ÿฐ ์ข…๋ฅ˜์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋ ˆ์ด๋ธ”์ด ์ง€์ •๋œ ์•„์ด์ฝ˜์„ ๋”ฐ๋ผํ•ด๋ณด์„ธ์š”.

Visual studio Code

๋ฐ”ํƒ• ํ™”๋ฉด์— 30DaysOfPython์ด๋ผ๋Š” ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฝ์‹œ๋‹ค.

Opening Project on Visual studio

Opening a project

ํŒŒ์ผ์„ ์—ด๋ฉด 30DaysOfPython ํ”„๋กœ์ ํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์— ํŒŒ์ผ๊ณผ ํด๋”๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด ์ฒซ ๋ฒˆ์งธ ํŒŒ์ผ์ธ helloworld.py๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ๋„ ๋˜‘๊ฐ™์ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Creating a python file

ํ•˜๋ฃจ๋™์•ˆ ์˜ค๋ž˜ ์ฝ”๋”ฉ์„ ํ•œ ํ›„์— ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ๋‹ซ๊ณ  ์‹ถ์Šต๋‹ˆ๊นŒ? ์ด๋ ‡๊ฒŒ ์—ด๋ฆฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ซ์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Closing project

์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ •์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์„ ์‹œ์ž‘ํ•ด ๋ด…์‹œ๋‹ค.

Python ๊ธฐ๋ณธ

Python ๊ตฌ๋ฌธ

Python ์Šคํฌ๋ฆฝํŠธ๋Š” Python ๋Œ€ํ™”ํ˜• ์…ธ ๋˜๋Š” ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ์—์„œ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Python ํŒŒ์ผ์˜ ํ™•์žฅ์ž๋Š” .py์ž…๋‹ˆ๋‹ค.

Python ๋“ค์—ฌ ์“ฐ๊ธฐ

๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ํ…์ŠคํŠธ์˜ ๊ณต๋ฐฑ์ž…๋‹ˆ๋‹ค. ๋งŽ์€ ์–ธ์–ด์—์„œ ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ Python์€ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ๋Š” ์ค‘๊ด„ํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋“ค์—ฌ์“ฐ๊ธฐ ๋Œ€์‹  ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. Python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ๋ฒ„๊ทธ ์ค‘ ํ•˜๋‚˜๋Š” ์ž˜๋ชป๋œ ๋“ค์—ฌ์“ฐ๊ธฐ์ž…๋‹ˆ๋‹ค.

Indentation Error

์ฃผ์„

์ฃผ์„์€ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ค๊ณ  ์ฝ”๋“œ์— ์„ค๋ช…์„ ๋‚จ๊ธฐ๊ธฐ ์œ„ํ•ด ๋งค์šฐ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. Python์€ ์ฝ”๋“œ์˜ ์ฃผ์„ ๋ถ€๋ถ„์„ ์‹คํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Python์—์„œ ํ•ด์‹œ(#)๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ชจ๋“  ํ…์ŠคํŠธ๋Š” ์ฃผ์„์ž…๋‹ˆ๋‹ค.

์˜ˆ์‹œ:ํ•œ ๋ฌธ์žฅ ์ฃผ์„

    # This is the first comment
    # This is the second comment
    # Python is eating the world

์˜ˆ์‹œ: ์—ฌ๋Ÿฌ ๋ฌธ์žฅ ์ฃผ์„

Triple quote can be used for multiline comment if it is not assigned to a variable

"""This is multiline comment
multiline comment takes multiple lines.
python is eating the world
"""

๋ฐ์ดํ„ฐ ํƒ€์ž…

Python์—๋Š” ์—ฌ๋Ÿฌ ์œ ํ˜•์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ธ ๊ฒƒ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ ๋‹ค๋ฅธ ์„น์…˜์—์„œ ์ž์„ธํžˆ ๋‹ค๋ฃฐ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋‹น๋ถ„๊ฐ„ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ์‚ดํŽด๋ณด๊ณ  ์ต์ˆ™ํ•ด์ง€๋„๋ก ํ•ฉ์‹œ๋‹ค. ์ง€๊ธˆ์€ ๋ช…ํ™•ํ•˜๊ฒŒ ์ดํ•ดํ•˜์ง€ ์•Š์•„๋„ ๋ฉ๋‹ˆ๋‹ค.

Number

  • Integer: ์ •์ˆ˜(์Œ์ˆ˜, ์˜ ๊ทธ๋ฆฌ๊ณ  ์–‘์ˆ˜) ์˜ˆ์‹œ: ... -3, -2, -1, 0, 1, 2, 3 ...
  • Float: ์‹ญ์ง„์ˆ˜ ์˜ˆ์‹œ ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ...
  • Complex ์˜ˆ์‹œ 1 + j, 2 + 4j

String

์ž‘์€๋”ฐ์˜ดํ‘œ ๋˜๋Š” ํฐ๋”ฐ์˜ดํ‘œ ์•„๋ž˜์— ์žˆ๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ๋ฌธ์ž ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์ด ๋‘ ๋ฌธ์žฅ ์ด์ƒ์ธ ๊ฒฝ์šฐ ์‚ผ์ค‘ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ์‹œ:

'Asabeneh'
'Finland'
'Python'
'I love teaching'
'I hope you are enjoying the first day of 30DaysOfPython Challenge'

Boolean

๋ถ€์šธ ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ True ๋˜๋Š” False ๊ฐ’์ž…๋‹ˆ๋‹ค. T์™€ F๋Š” ํ•ญ์ƒ ๋Œ€๋ฌธ์ž์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ์‹œ:

    True  #  ๋ถˆ์ด ์ผœ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ์ฐธ์ž…๋‹ˆ๋‹ค.
    False # ๋ถˆ์ด ๊บผ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ๊ฑฐ์ง“์ž…๋‹ˆ๋‹ค.

List

Python ๋ฆฌ์ŠคํŠธ๋Š” ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ ์œ ํ˜• ํ•ญ๋ชฉ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ ฌ๋œ ์ปฌ๋ ‰์…˜์ž…๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ๋Š” JavaScript์˜ ๋ฐฐ์—ด๊ณผ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค.

Example:

[0, 1, 2, 3, 4, 5]  # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ์ˆซ์ž ๋ฆฌ์ŠคํŠธ
['Banana', 'Orange', 'Mango', 'Avocado'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ณผ์ผ)
['Finland','Estonia', 'Sweden','Norway'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ตญ๊ฐ€)
['Banana', 10, False, 9.81] # ๋ฆฌ์ŠคํŠธ์˜ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด, ์ •์ˆ˜, ๋ถ€์šธ ๋ฐ ๋ถ€๋™ ์†Œ์ˆ˜์ 

Dictionary

Python ์‚ฌ์ „ ๊ฐœ์ฒด๋Š” ํ‚ค ๊ฐ’ ์Œ ํ˜•์‹์˜ ์ •๋ ฌ๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค.

Example:

{
'first_name':'Asabeneh',
'last_name':'Yetayeh',
'country':'Finland', 
'age':250, 
'is_married':True,
'skills':['JS', 'React', 'Node', 'Python']
}

Tuple

ํŠœํ”Œ์€ ๋ชฉ๋ก๊ณผ ๊ฐ™์€ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ์ •๋ ฌ๋œ ๋ชจ์Œ์ด์ง€๋งŒ ํŠœํ”Œ์ด ์ƒ์„ฑ๋˜๋ฉด ์ˆ˜์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ๋“ค์€ ๋ณ€ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

Example:

('Asabeneh', 'Pawel', 'Brook', 'Abraham', 'Lidiya') # Names
('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets

Set

์ง‘ํ•ฉ์€ ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ์œ ์‚ฌํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ๋‹ฌ๋ฆฌ ์ง‘ํ•ฉ์€ ์ˆœ์„œ๊ฐ€ ์ง€์ •๋œ ํ•ญ๋ชฉ ๋ชจ์Œ์ด ์•„๋‹™๋‹ˆ๋‹ค. ์ˆ˜ํ•™์—์„œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ Python์—์„œ set์€ ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ๋งŒ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

์ดํ›„ ์„น์…˜์—์„œ๋Š” ๊ฐ๊ฐ์˜ ๋ชจ๋“  Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

Example:

{2, 4, 3, 5}
{3.14, 9.81, 2.7} # order is not important in set

๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ

ํŠน์ • ๋ฐ์ดํ„ฐ/๋ณ€์ˆ˜์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด type ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์–‘ํ•œ Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

Checking Data types

Python ํŒŒ์ผ

๋จผ์ € ํ”„๋กœ์ ํŠธ ํด๋”์ธ 30DaysOfPython์„ ์—ฝ๋‹ˆ๋‹ค. ์ด ํด๋”๊ฐ€ ์—†์œผ๋ฉด 30DaysOfPython์ด๋ผ๋Š” ํด๋” ์ด๋ฆ„์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด ํด๋” ์•ˆ์— helloworld.py๋ผ๋Š” ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด์ œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ˆ˜ํ–‰ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Python ๋Œ€ํ™”ํ˜• ์…ธ์€ print๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ธ์‡„ํ–ˆ์ง€๋งŒ Visual Studio ์ฝ”๋“œ์—์„œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ ค๋ฉด ๋‚ด์žฅ ํ•จ์ˆ˜ print()๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. print() ๋‚ด์žฅ ํ•จ์ˆ˜๋Š” print('arument1', 'argument2', 'argument3')*์™€ ๊ฐ™์ด ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.

Example:

ํŒŒ์ผ ์ด๋ฆ„์€ helloworld.py.

# Day 1 - 30DaysOfPython Challenge

print(2 + 3)             # addition(+)
print(3 - 1)             # subtraction(-)
print(2 * 3)             # multiplication(*)
print(3 / 2)             # division(/)
print(3 ** 2)            # exponential(**)
print(3 % 2)             # modulus(%)
print(3 // 2)            # Floor division operator(//)

# Checking data types
print(type(10))          # Int
print(type(3.14))        # Float
print(type(1 + 3j))      # Complex number
print(type('Asabeneh'))  # String
print(type([1, 2, 3]))   # List
print(type({'name':'Asabeneh'})) # Dictionary
print(type({9.8, 3.14, 2.7}))    # Set
print(type((9.8, 3.14, 2.7)))    # Tuple

Python ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ ค๋ฉด ์•„๋ž˜ ์ด๋ฏธ์ง€๋ฅผ ํ™•์ธํ•˜์„ธ์š”. Visual Studio Code์—์„œ ๋…น์ƒ‰ ๋ฒ„ํŠผ์„ ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜ ํ„ฐ๋ฏธ๋„์— python helloworld.py๋ฅผ ์ž…๋ ฅํ•˜์—ฌ Python ํŒŒ์ผ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Running python script

๐ŸŒ• ์ข‹์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 1์ผ์ฐจ ๋„์ „์„ ์™„๋ฃŒํ–ˆ๊ณ  ๋‹น์‹ ์€ ์œ„๋Œ€ํ•œ ์—ฌ์ •์— ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•ด๋ด…์‹œ๋‹ค.

๐Ÿ’ป Exercises - Day 1

Exercise: Level 1

  1. ์‚ฌ์šฉ ์ค‘์ธ Python ๋ฒ„์ „ ํ™•์ธ
  2. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ด๊ณ  ๋‹ค์Œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ํ”ผ์—ฐ์‚ฐ์ž๋Š” 3๊ณผ 4์ž…๋‹ˆ๋‹ค.
  3. ๋”ํ•˜๊ธฐ(+)
  4. ๋นผ๊ธฐ(-)
  5. ๊ณฑํ•˜๊ธฐ(*)
  6. ๋‚˜๋จธ์ง€(%)
  7. ๋‚˜๋ˆ„๊ธฐ(/)
  8. ์ง€์ˆ˜(**)
  9. ์ •์ˆ˜ ๋‚˜๋ˆ„๊ธฐ(//)
  10. Python ๋Œ€ํ™”ํ˜• ์…ธ์— ๋ฌธ์ž์—ด์„ ์”๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:
  11. ์ด๋ฆ„
  12. ๊ฐ€์กฑ ์ด๋ฆ„
  13. ๊ตญ๊ฐ€ ์ด๋ฆ„
  14. I am enjoying 30 days of python
  15. ๋‹ค์Œ ๋ฐ์ดํ„ฐ์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.:
  16. 10
  17. 9.8
  18. 3.14
  19. 4 - 4j
  20. ['Asabeneh', 'Python', 'Finland']
  21. ์ด๋ฆ„
  22. ๊ฐ€์กฑ ์ด๋ฆ„
  23. ๊ตญ๊ฐ€ ์ด๋ฆ„

Exercise: Level 2

  1. 30DaysOfPython ํด๋” ์•ˆ์— day_1์ด๋ผ๋Š” ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. day_1 ํด๋” ์•ˆ์— python ํŒŒ์ผ helloworld.py๋ฅผ ๋งŒ๋“ค๊ณ  ์งˆ๋ฌธ 1, 2, 3, 4๋ฅผ ๋ฐ˜๋ณตํ•˜์„ธ์š”. Python ํŒŒ์ผ์—์„œ ์ž‘์—…ํ•  ๋•Œ _print()_๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์žŠ์ง€ ๋งˆ์„ธ์š”. ํŒŒ์ผ์„ ์ €์žฅํ•œ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•˜์—ฌ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

Exercise: Level 3

  1. Number(Integer, Float, Complex), String, Boolean, List, Tuple, Set ๋ฐ Dictionary์™€ ๊ฐ™์€ ๋‹ค์–‘ํ•œ Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์— ๋Œ€ํ•œ ์˜ˆ์ œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
  2. ์ฐธ๊ณ  Euclidian distance (2, 3) ๊ณผ (10, 8) ์‚ฌ์ด

๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค ! ๐ŸŽ‰

Day 2 >>