From 870fe340a946b28abf7bc5b399e1bc7f5dc102f0 Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Wed, 7 Dec 2022 14:34:53 +0900 Subject: [PATCH 1/8] kor ver --- lang-ko/readme_ko.md | 454 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 lang-ko/readme_ko.md diff --git a/lang-ko/readme_ko.md b/lang-ko/readme_ko.md new file mode 100644 index 00000000..770ee592 --- /dev/null +++ b/lang-ko/readme_ko.md @@ -0,0 +1,454 @@ +# ๐Ÿ 30 Days Of Python + +|# Day | Topics | +|------|:---------------------------------------------------------:| +| 01 | [Introduction](./readme.md)| +| 02 | [Variables, Built-in Functions](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)| +| 03 | [Operators](./03_Day_Operators/03_operators.md)| +| 04 | [Strings](./04_Day_Strings/04_strings.md)| +| 05 | [Lists](./05_Day_Lists/05_lists.md)| +| 06 | [Tuples](./06_Day_Tuples/06_tuples.md)| +| 07 | [Sets](./07_Day_Sets/07_sets.md)| +| 08 | [Dictionaries](./08_Day_Dictionaries/08_dictionaries.md)| +| 09 | [Conditionals](./09_Day_Conditionals/09_conditionals.md)| +| 10 | [Loops](./10_Day_Loops/10_loops.md)| +| 11 | [Functions](./11_Day_Functions/11_functions.md)| +| 12 | [Modules](./12_Day_Modules/12_modules.md)| +| 13 | [List Comprehension](./13_Day_List_comprehension/13_list_comprehension.md)| +| 14 | [Higher Order Functions](./14_Day_Higher_order_functions/14_higher_order_functions.md)| +| 15 | [Python Type Errors](./15_Day_Python_type_errors/15_python_type_errors.md)| +| 16 | [Python Date time](./16_Day_Python_date_time/16_python_datetime.md) | +| 17 | [Exception Handling](./17_Day_Exception_handling/17_exception_handling.md)| +| 18 | [Regular Expressions](./18_Day_Regular_expressions/18_regular_expressions.md)| +| 19 | [File Handling](./19_Day_File_handling/19_file_handling.md)| +| 20 | [Python Package Manager](./20_Day_Python_package_manager/20_python_package_manager.md)| +| 21 | [Classes and Objects](./21_Day_Classes_and_objects/21_classes_and_objects.md)| +| 22 | [Web Scraping](./22_Day_Web_scraping/22_web_scraping.md)| +| 23 | [Virtual Environment](./23_Day_Virtual_environment/23_virtual_environment.md)| +| 24 | [Statistics](./24_Day_Statistics/24_statistics.md)| +| 25 | [Pandas](./25_Day_Pandas/25_pandas.md)| +| 26 | [Python web](./26_Day_Python_web/26_python_web.md)| +| 27 | [Python with MongoDB](./27_Day_Python_with_mongodb/27_python_with_mongodb.md)| +| 28 | [API](./28_Day_API/28_API.md)| +| 29 | [Building API](./29_Day_Building_API/29_building_API.md)| +| 30 | [Conclusions](./30_Day_Conclusions/30_conclusions.md)| + +๐Ÿงก๐Ÿงก๐Ÿงก 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 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) + +![30DaysOfPython](./images/30DaysOfPython_banner3@2x.png) + +- [๐Ÿ 30 Days Of Python](#-30-days-of-python) +- [๐Ÿ“˜ Day 1](#-day-1) + - [ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค](#welcome) + - [์†Œ๊ฐœ](#introduction) + - [์™œ Python์ด๋Š๋ƒ?](#why-python-) + - [ํ™˜๊ฒฝ ์„ค์ •](#environment-setup) + - [Python ์„ค์น˜](#installing-python) + - [Python ์…ธ](#python-shell) + - [Visual Studio Code ์„ค์น˜](#installing-visual-studio-code) + - [visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ](#how-to-use-visual-studio-code) + - [Python ๊ธฐ๋ณธ](#basic-python) + - [Python ๊ตฌ๋ฌธ](#python-syntax) + - [Python ๋“ค์—ฌ์“ฐ๊ธฐ](#python-indentation) + - [์ฃผ์„](#comments) + - [๋ฐ์ดํ„ฐ ํƒ€์ž…](#data-types) + - [Number](#number) + - [String](#string) + - [Booleans](#booleans) + - [List](#list) + - [Dictionary](#dictionary) + - [Tuple](#tuple) + - [Set](#set) + - [๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ](#checking-data-types) + - [Python ํŒŒ์ผ](#python-file) + - [๐Ÿ’ป Exercises - Day 1](#-exercises---day-1) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercise: Level 3](#exercise-level-3) + +# ๐Ÿ“˜ Day 1 + +## ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค + +_30 days of Python_์— ์ฐธ์—ฌํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ•˜์‹  ๊ฒƒ์„ **์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค**. ์ด ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ๋˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ๋ชจ๋“  ๊ฒƒ๊ณผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ์ „์ฒด ๊ฐœ๋…์„ ๋ฐฐ์šฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๊ฐ€ ๋๋‚˜๋ฉด _30DaysOfPython_ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ์„œ๋ฅผ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. + +์ฑŒ๋ฆฐ์ง€์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด [30DaysOfPython challenge](https://t.me/ThirtyDaysOfPython) ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ๊ฐ€์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +## ์†Œ๊ฐœ + +Python์€ ๋ฒ”์šฉ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•œ ๊ณ ๊ธ‰ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์˜คํ”ˆ ์†Œ์Šค, ์ธํ„ฐํ”„๋ฆฌํ„ฐ, ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Python์€ ๋„ค๋œ๋ž€๋“œ ํ”„๋กœ๊ทธ๋ž˜๋จธ Guido van Rossum์ด ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์˜ ์ด๋ฆ„์€ ์˜๊ตญ ์Šค์ผ€์น˜ ์ฝ”๋ฏธ๋”” ์‹œ๋ฆฌ์ฆˆ *Month Python's Flying Circus* ์—์„œ ํŒŒ์ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ๋ฒ„์ „์€ 1991๋…„ 2์›” 20์ผ์— ์ถœ์‹œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ์ฑŒ๋ฆฐ์ง€๋Š” ์ตœ์‹  ๋ฒ„์ „์˜ Python์ธ Python 3๋ฅผ ์ฐจ๊ทผ์ฐจ๊ทผ ๋ฐฐ์šธ ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฃผ์ œ๋Š” 30์ผ๋กœ ๋‚˜๋‰˜๋ฉฐ, ๋งค์ผ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์„ค๋ช…, ์‹ค์ œ ์‚ฌ๋ก€, ๋งŽ์€ ์‹ค์Šต ๋ฐ ํ”„๋กœ์ ํŠธ๊ฐ€ ํฌํ•จ๋œ ์—ฌ๋Ÿฌ ์ฃผ์ œ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. + +์ด ์ฑŒ๋ฆฐ์ง€๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ๋ฐฐ์šฐ๊ณ ์ž ํ•˜๋Š” ์ดˆ๋ณด์ž์™€ ์ „๋ฌธ๊ฐ€๋ฅผ ์œ„ํ•ด ๊ณ ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•˜๋Š” ๋ฐ 30~100์ผ์ด ์†Œ์š”๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์ด ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•  ํ™•๋ฅ ์ด ๋†’์Šต๋‹ˆ๋‹ค. +์‹œ๊ฐ์  ํ•™์Šต์ž์ด๊ฑฐ๋‚˜ ๋™์˜์ƒ์„ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ ์ด [์™„์ „ ์ดˆ๋ณด๋ฅผ ์œ„ํ•œ Python ๋™์˜์ƒ](https://www.youtube.com/watch?v=11OYpBrhdyM)์œผ๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +## ์™œ Python์ด๋Š๋ƒ? + +์ธ๊ฐ„์˜ ์–ธ์–ด์— ๋งค์šฐ ๊ฐ€๊น๊ณ  ๋ฐฐ์šฐ๊ธฐ ์‰ฝ๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฌ์šด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. +Python์€ ๋‹ค์–‘ํ•œ ์‚ฐ์—… ๋ฐ ํšŒ์‚ฌ(Google ํฌํ•จ)์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์›น ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ๋ฐ์Šคํฌํ†ฑ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ์‹œ์Šคํ…œ ๊ด€๋ฆฌ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Python์€ ๋ฐ์ดํ„ฐ ๊ณผํ•™ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ์ปค๋ฎค๋‹ˆํ‹ฐ์—์„œ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด Python ํ•™์Šต์„ ์‹œ์ž‘ํ•˜๋„๋ก ์„ค๋“ํ•˜๊ธฐ์— ์ถฉ๋ถ„ํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. Python์€ ์„ธ์ƒ์„ ์ง€๋ฐฐํ•˜๊ณ  ์žˆ์œผ๋‹ˆ ์ง€๋ฐฐ ๋‹นํ•˜๊ธฐ ์ „์— Python์„ ์ง€๋ฐฐํ•˜์‹ญ์‹œ์˜ค. +## ํ™˜๊ฒฝ ์„ค์ • + +### Python ์„ค์น˜ + +Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด Python์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python์„ [๋‹ค์šด๋กœ๋“œ](https://www.python.org/)ํ•ฉ์‹œ๋‹ค. +Windows ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. + + + +macOS ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. + +[![Windows์—์„œ ์„ค์น˜](./images/installing_on_windows.png)](https://www.python.org/) + +Python์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ์žฅ์น˜ ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค. + +```shell +python --version +``` + +![Python Version](./images/python_versio.png) + +ํ„ฐ๋ฏธ๋„์—์„œ ๋ณด์‹œ๋‹ค์‹œํ”ผ ์ €๋Š” ํ˜„์žฌ _Python 3.7.5_ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ Python ๋ฒ„์ „์€ ๋‚ด ๋ฒ„์ „๊ณผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์ง€๋งŒ 3.6 ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python ๋ฒ„์ „์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ž˜ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์ปดํ“จํ„ฐ์— Python์ด ์„ค์น˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์„น์…˜์œผ๋กœ ๊ณ„์† ์ง„ํ–‰ํ•˜์‹ญ์‹œ์˜ค. + +### Python ์…ธ + +Python์€ ํ•ด์„๋œ ์Šคํฌ๋ฆฝํŒ… ์–ธ์–ด์ด๋ฏ€๋กœ ์ปดํŒŒ์ผํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ํ•œ ์ค„์”ฉ ์‹คํ–‰ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. Python์€ _Python Shell(Python Interactive Shell)_๊ณผ ํ•จ๊ป˜ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ๋‹จ์ผ Python ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. + +Python Shell์€ ์‚ฌ์šฉ์ž์˜ Python ์ฝ”๋“œ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•˜์—ฌ ๋‹ค์Œ ์ค„์— ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. +ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ(cmd)๋ฅผ ์—ด๊ณ  ์“ฐ๊ธฐ: + +```shell +python +``` + +![Python Scripting Shell](./images/opening_python_shell.png) + +Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฌ๊ณ  Python ์ฝ”๋“œ(Python ์Šคํฌ๋ฆฝํŠธ)๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ๊ธฐํ˜ธ >>> ์˜†์— Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  Enter๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. +Python ์Šคํฌ๋ฆฝํŒ… ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + +![Python script on Python shell](./images/adding_on_python_shell.png) + +ํ›Œ๋ฅญํ•ฉ๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์–ด๋–ป๊ฒŒ ๋‹ซ์Šต๋‹ˆ๊นŒ? +์…ธ์„ ๋‹ซ์œผ๋ ค๋ฉด ๊ธฐํ˜ธ ์˜†์— >> **exit()** ๋ช…๋ น์„ ์ž‘์„ฑํ•˜๊ณ  Enter ํ‚ค๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. + +![Exit from python shell](./images/exit_from_shell.png) + +์ด์ œ Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ฌ๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•˜์Šต๋‹ˆ๋‹ค. + +Python์€ Python์ด ์ดํ•ดํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ณ ์˜์ ์ธ ์‹ค์ˆ˜๋ฅผ ํ•˜๊ณ  Python์ด ๋ฌด์—‡์„ ๋ฐ˜ํ™˜ํ•˜๋Š”์ง€ ๋ด…์‹œ๋‹ค. + +![Invalid Syntax Error](./images/invalid_syntax_error.png) + +๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด Python์€ ์šฐ๋ฆฌ๊ฐ€ ์ €์ง€๋ฅธ ์‹ค์ˆ˜์™€ _Syntax Error: invalid syntax_๋ฅผ ์•Œ๊ณ  ์žˆ์„ ์ •๋„๋กœ ์˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. Python์—์„œ x๋ฅผ ๊ณฑ์…ˆ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ (x)๊ฐ€ Python์—์„œ ์œ ํšจํ•œ ๊ตฌ๋ฌธ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. (**x**) ๋Œ€์‹  ๊ณฑ์…ˆ์— ๋ณ„ํ‘œ(*)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜๋Š” ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. + +ํ”„๋กœ๊ทธ๋žจ์—์„œ ์˜ค๋ฅ˜๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์ œ๊ฑฐํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ *๋””๋ฒ„๊น…*์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. **x** ๋Œ€์‹  *๋ฅผ ๋„ฃ์–ด ๋””๋ฒ„๊น…ํ•ด ๋ด…์‹œ๋‹ค. + +![Fixing Syntax Error](./images/fixing_syntax_error.png) + +๋ฒ„๊ทธ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ๊ณ  ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋˜์—ˆ์œผ๋ฉฐ ์˜ˆ์ƒํ–ˆ๋˜ ๊ฒฐ๊ณผ๋ฅผ ์–ป์—ˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ๋กœ์„œ ๋งค์ผ ์ด๋Ÿฌํ•œ ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๋ฅผ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•์„ ์•„๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋””๋ฒ„๊น…์„ ์ž˜ํ•˜๋ ค๋ฉด ์–ด๋–ค ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์ดํ•ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” Python ์˜ค๋ฅ˜ ์ค‘ ์ผ๋ถ€๋Š” *SyntaxError*, *IndexError*, *NameError*, *ModuleNotFoundError*, *KeyError*, *ImportError*, *AttributeError*, *TypeError*, *ValueError*, *ZeroDivisionError* ๋“ฑ์ž…๋‹ˆ๋‹ค. ์ดํ›„ ์„น์…˜์—์„œ ๋‹ค๋ฅธ Python **_์˜ค๋ฅ˜ ์œ ํ˜•_**์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค. + +Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋” ์—ฐ์Šตํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋™ํ•˜์—ฌ **python**์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์”๋‹ˆ๋‹ค. + +![Python Scripting Shell](./images/opening_python_shell.png) + +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์—์„œ ์ฃผ์„์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค + +```shell + # ์ฃผ์„์€ ํ•ด์‹œ๋กœ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. + # (#) ์‹ฌ๋ณผ๋กœ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์€ ํŒŒ์ด์ฌ ์ฃผ์„์ž…๋‹ˆ๋‹ค. +``` + +![Maths on python shell](./images/maths_on_python_shell.png) + +๋‹ค์Œ ์„น์…˜์œผ๋กœ ์ด๋™ํ•˜๊ธฐ ์ „์— Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ๋” ๋งŽ์€ ์—ฐ์Šต์„ ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์…ธ์—์„œ _exit()_๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์—ด๋ฆฐ ์…ธ์„ ๋‹ซ์•˜๋‹ค๊ฐ€ ๋‹ค์‹œ ์—ด์–ด Python ์…ธ์—์„œ ํ…์ŠคํŠธ๋ฅผ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์„ ์—ฐ์Šตํ•ด ๋ด…์‹œ๋‹ค. + +![Writing String on python shell](./images/writing_string_on_shell.png) + +### Visual Studio Code ์„ค์น˜ + +Python ๋Œ€ํ™”ํ˜• ์…ธ์€ ์ž‘์€ ์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์‹œ๋„ํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•˜๋Š” ๋ฐ ์ ํ•ฉํ•˜์ง€๋งŒ ํฐ ํ”„๋กœ์ ํŠธ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์ž‘์—… ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ์ž๋Š” ๋‹ค์–‘ํ•œ ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Visual Studio Code๋Š” ๋งค์šฐ ์ธ๊ธฐ ์žˆ๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ…์ŠคํŠธ ํŽธ์ง‘๊ธฐ์ž…๋‹ˆ๋‹ค. ๋‚˜๋Š” vscode์˜ ํŒฌ์ด๊ณ  Visual Studio ์ฝ”๋“œ๋ฅผ [๋‹ค์šด๋กœ๋“œ](https://code.visualstudio.com/)ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•˜๊ณ  ์‹ถ์ง€๋งŒ, ๋‹ค๋ฅธ ํŽธ์ง‘์ž๋ฅผ ์„ ํ˜ธํ•œ๋‹ค๋ฉด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์ž์œ ๋กญ๊ฒŒ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค. + +[![Visual Studio Code](./images/vscode.png)](https://code.visualstudio.com/) + +Visual Studio Code๋ฅผ ์„ค์น˜ํ•˜์…จ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. +๋น„๋””์˜ค๋ฅผ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ Python์šฉ Visual Studio Code[๋น„๋””์˜ค ์ž์Šต์„œ](https://www.youtube.com/watch?v=bn7Cx4z-vSo)๋ฅผ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +#### visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ + +Visual Studio ์•„์ด์ฝ˜์„ ๋‘ ๋ฒˆ ํด๋ฆญํ•˜์—ฌ Visual Studio ์ฝ”๋“œ๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ์—ด๋ฉด ์ด๋Ÿฐ ์ข…๋ฅ˜์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋ ˆ์ด๋ธ”์ด ์ง€์ •๋œ ์•„์ด์ฝ˜์„ ๋”ฐ๋ผํ•ด๋ณด์„ธ์š”. + +![Visual studio Code](./images/vscode_ui.png) + +๋ฐ”ํƒ• ํ™”๋ฉด์— 30DaysOfPython์ด๋ผ๋Š” ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฝ์‹œ๋‹ค. + +![Opening Project on Visual studio](./images/how_to_open_project_on_vscode.png) + +![Opening a project](./images/opening_project.png) + +ํŒŒ์ผ์„ ์—ด๋ฉด 30DaysOfPython ํ”„๋กœ์ ํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์— ํŒŒ์ผ๊ณผ ํด๋”๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด ์ฒซ ๋ฒˆ์งธ ํŒŒ์ผ์ธ helloworld.py๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ๋„ ๋˜‘๊ฐ™์ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +![Creating a python file](./images/helloworld.png) + +ํ•˜๋ฃจ๋™์•ˆ ์˜ค๋ž˜ ์ฝ”๋”ฉ์„ ํ•œ ํ›„์— ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ๋‹ซ๊ณ  ์‹ถ์Šต๋‹ˆ๊นŒ? ์ด๋ ‡๊ฒŒ ์—ด๋ฆฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ซ์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. + +![Closing project](./images/closing_opened_project.png) + +์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ •์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์„ ์‹œ์ž‘ํ•ด ๋ด…์‹œ๋‹ค. + +## Python ๊ธฐ๋ณธ + +### Python ๊ตฌ๋ฌธ + +Python ์Šคํฌ๋ฆฝํŠธ๋Š” Python ๋Œ€ํ™”ํ˜• ์…ธ ๋˜๋Š” ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ์—์„œ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Python ํŒŒ์ผ์˜ ํ™•์žฅ์ž๋Š” .py์ž…๋‹ˆ๋‹ค. + +### Python ๋“ค์—ฌ ์“ฐ๊ธฐ + +๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ํ…์ŠคํŠธ์˜ ๊ณต๋ฐฑ์ž…๋‹ˆ๋‹ค. ๋งŽ์€ ์–ธ์–ด์—์„œ ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ Python์€ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ๋Š” ์ค‘๊ด„ํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋“ค์—ฌ์“ฐ๊ธฐ ๋Œ€์‹  ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. Python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ๋ฒ„๊ทธ ์ค‘ ํ•˜๋‚˜๋Š” ์ž˜๋ชป๋œ ๋“ค์—ฌ์“ฐ๊ธฐ์ž…๋‹ˆ๋‹ค. + +![Indentation Error](./images/indentation.png) + +### ์ฃผ์„ + +์ฃผ์„์€ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ค๊ณ  ์ฝ”๋“œ์— ์„ค๋ช…์„ ๋‚จ๊ธฐ๊ธฐ ์œ„ํ•ด ๋งค์šฐ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. Python์€ ์ฝ”๋“œ์˜ ์ฃผ์„ ๋ถ€๋ถ„์„ ์‹คํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. +Python์—์„œ ํ•ด์‹œ(#)๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ชจ๋“  ํ…์ŠคํŠธ๋Š” ์ฃผ์„์ž…๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:ํ•œ ๋ฌธ์žฅ ์ฃผ์„** + +```shell + # 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 + +```shell +"""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 + +์ž‘์€๋”ฐ์˜ดํ‘œ ๋˜๋Š” ํฐ๋”ฐ์˜ดํ‘œ ์•„๋ž˜์— ์žˆ๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ๋ฌธ์ž ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์ด ๋‘ ๋ฌธ์žฅ ์ด์ƒ์ธ ๊ฒฝ์šฐ ์‚ผ์ค‘ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:** + +```py +'Asabeneh' +'Finland' +'Python' +'I love teaching' +'I hope you are enjoying the first day of 30DaysOfPython Challenge' +``` + +#### Boolean + +๋ถ€์šธ ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ True ๋˜๋Š” False ๊ฐ’์ž…๋‹ˆ๋‹ค. T์™€ F๋Š” ํ•ญ์ƒ ๋Œ€๋ฌธ์ž์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:** + +```python + True # ๋ถˆ์ด ์ผœ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ์ฐธ์ž…๋‹ˆ๋‹ค. + False # ๋ถˆ์ด ๊บผ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ๊ฑฐ์ง“์ž…๋‹ˆ๋‹ค. +``` + +#### List + +Python ๋ฆฌ์ŠคํŠธ๋Š” ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ ์œ ํ˜• ํ•ญ๋ชฉ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ ฌ๋œ ์ปฌ๋ ‰์…˜์ž…๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ๋Š” JavaScript์˜ ๋ฐฐ์—ด๊ณผ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค. + +**Example:** + +```py +[0, 1, 2, 3, 4, 5] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ์ˆซ์ž ๋ฆฌ์ŠคํŠธ +['Banana', 'Orange', 'Mango', 'Avocado'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ณผ์ผ) +['Finland','Estonia', 'Sweden','Norway'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ตญ๊ฐ€) +['Banana', 10, False, 9.81] # ๋ฆฌ์ŠคํŠธ์˜ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด, ์ •์ˆ˜, ๋ถ€์šธ ๋ฐ ๋ถ€๋™ ์†Œ์ˆ˜์  +``` + +#### Dictionary + +Python ์‚ฌ์ „ ๊ฐœ์ฒด๋Š” ํ‚ค ๊ฐ’ ์Œ ํ˜•์‹์˜ ์ •๋ ฌ๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. + +**Example:** + +```py +{ +'first_name':'Asabeneh', +'last_name':'Yetayeh', +'country':'Finland', +'age':250, +'is_married':True, +'skills':['JS', 'React', 'Node', 'Python'] +} +``` + +#### Tuple + +ํŠœํ”Œ์€ ๋ชฉ๋ก๊ณผ ๊ฐ™์€ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ์ •๋ ฌ๋œ ๋ชจ์Œ์ด์ง€๋งŒ ํŠœํ”Œ์ด ์ƒ์„ฑ๋˜๋ฉด ์ˆ˜์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ๋“ค์€ ๋ณ€ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. + +**Example:** + +```py +('Asabeneh', 'Pawel', 'Brook', 'Abraham', 'Lidiya') # Names +``` + +```py +('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets +``` + +#### Set + +์ง‘ํ•ฉ์€ ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ์œ ์‚ฌํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ๋‹ฌ๋ฆฌ ์ง‘ํ•ฉ์€ ์ˆœ์„œ๊ฐ€ ์ง€์ •๋œ ํ•ญ๋ชฉ ๋ชจ์Œ์ด ์•„๋‹™๋‹ˆ๋‹ค. ์ˆ˜ํ•™์—์„œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ Python์—์„œ set์€ ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ๋งŒ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. + +์ดํ›„ ์„น์…˜์—์„œ๋Š” ๊ฐ๊ฐ์˜ ๋ชจ๋“  Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. + +**Example:** + +```py +{2, 4, 3, 5} +{3.14, 9.81, 2.7} # order is not important in set +``` + +### ๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ + +ํŠน์ • ๋ฐ์ดํ„ฐ/๋ณ€์ˆ˜์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด **type** ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์–‘ํ•œ Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: + +![Checking Data types](./images/checking_data_types.png) + +### Python ํŒŒ์ผ + +๋จผ์ € ํ”„๋กœ์ ํŠธ ํด๋”์ธ 30DaysOfPython์„ ์—ฝ๋‹ˆ๋‹ค. ์ด ํด๋”๊ฐ€ ์—†์œผ๋ฉด 30DaysOfPython์ด๋ผ๋Š” ํด๋” ์ด๋ฆ„์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด ํด๋” ์•ˆ์— helloworld.py๋ผ๋Š” ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด์ œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ˆ˜ํ–‰ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + +Python ๋Œ€ํ™”ํ˜• ์…ธ์€ **print**๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ธ์‡„ํ–ˆ์ง€๋งŒ Visual Studio ์ฝ”๋“œ์—์„œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ ค๋ฉด ๋‚ด์žฅ ํ•จ์ˆ˜ *print()๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. *print()* ๋‚ด์žฅ ํ•จ์ˆ˜๋Š” *print('arument1', 'argument2', 'argument3')*์™€ ๊ฐ™์ด ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. + +**Example:** + +ํŒŒ์ผ ์ด๋ฆ„์€ helloworld.py. + +```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](./images/running_python_script.png) + +๐ŸŒ• ์ข‹์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 1์ผ์ฐจ ๋„์ „์„ ์™„๋ฃŒํ–ˆ๊ณ  ๋‹น์‹ ์€ ์œ„๋Œ€ํ•œ ์—ฌ์ •์— ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•ด๋ด…์‹œ๋‹ค. + +## ๐Ÿ’ป Exercises - Day 1 + +### Exercise: Level 1 + +1. ์‚ฌ์šฉ ์ค‘์ธ Python ๋ฒ„์ „ ํ™•์ธ +2. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ด๊ณ  ๋‹ค์Œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ํ”ผ์—ฐ์‚ฐ์ž๋Š” 3๊ณผ 4์ž…๋‹ˆ๋‹ค. + - ๋”ํ•˜๊ธฐ(+) + - ๋นผ๊ธฐ(-) + - ๊ณฑํ•˜๊ธฐ(\*) + - ๋‚˜๋จธ์ง€(%) + - ๋‚˜๋ˆ„๊ธฐ(/) + - ์ง€์ˆ˜(\*\*) + - ์ •์ˆ˜ ๋‚˜๋ˆ„๊ธฐ(//) +3. Python ๋Œ€ํ™”ํ˜• ์…ธ์— ๋ฌธ์ž์—ด์„ ์”๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: + - ์ด๋ฆ„ + - ๊ฐ€์กฑ ์ด๋ฆ„ + - ๊ตญ๊ฐ€ ์ด๋ฆ„ + - I am enjoying 30 days of python +4. ๋‹ค์Œ ๋ฐ์ดํ„ฐ์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.: + - 10 + - 9.8 + - 3.14 + - 4 - 4j + - ['Asabeneh', 'Python', 'Finland'] + - ์ด๋ฆ„ + - ๊ฐ€์กฑ ์ด๋ฆ„ + - ๊ตญ๊ฐ€ ์ด๋ฆ„ + +### 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](https://en.wikipedia.org/wiki/Euclidean_distance#:~:text=In%20mathematics%2C%20the%20Euclidean%20distance,being%20called%20the%20Pythagorean%20distance.) (2, 3) ๊ณผ (10, 8) ์‚ฌ์ด + +๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค ! ๐ŸŽ‰ + +[Day 2 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) \ No newline at end of file From c1364a4a5ec8f1c8dc4819620ca68690ac6377d6 Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Thu, 8 Dec 2022 13:13:09 +0900 Subject: [PATCH 2/8] lang ko --- lang-ko/readme_ko.md | 136 +++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/lang-ko/readme_ko.md b/lang-ko/readme_ko.md index 770ee592..558efe95 100644 --- a/lang-ko/readme_ko.md +++ b/lang-ko/readme_ko.md @@ -2,42 +2,42 @@ |# Day | Topics | |------|:---------------------------------------------------------:| -| 01 | [Introduction](./readme.md)| -| 02 | [Variables, Built-in Functions](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)| -| 03 | [Operators](./03_Day_Operators/03_operators.md)| -| 04 | [Strings](./04_Day_Strings/04_strings.md)| -| 05 | [Lists](./05_Day_Lists/05_lists.md)| -| 06 | [Tuples](./06_Day_Tuples/06_tuples.md)| -| 07 | [Sets](./07_Day_Sets/07_sets.md)| -| 08 | [Dictionaries](./08_Day_Dictionaries/08_dictionaries.md)| -| 09 | [Conditionals](./09_Day_Conditionals/09_conditionals.md)| -| 10 | [Loops](./10_Day_Loops/10_loops.md)| -| 11 | [Functions](./11_Day_Functions/11_functions.md)| -| 12 | [Modules](./12_Day_Modules/12_modules.md)| -| 13 | [List Comprehension](./13_Day_List_comprehension/13_list_comprehension.md)| -| 14 | [Higher Order Functions](./14_Day_Higher_order_functions/14_higher_order_functions.md)| -| 15 | [Python Type Errors](./15_Day_Python_type_errors/15_python_type_errors.md)| -| 16 | [Python Date time](./16_Day_Python_date_time/16_python_datetime.md) | -| 17 | [Exception Handling](./17_Day_Exception_handling/17_exception_handling.md)| -| 18 | [Regular Expressions](./18_Day_Regular_expressions/18_regular_expressions.md)| -| 19 | [File Handling](./19_Day_File_handling/19_file_handling.md)| -| 20 | [Python Package Manager](./20_Day_Python_package_manager/20_python_package_manager.md)| -| 21 | [Classes and Objects](./21_Day_Classes_and_objects/21_classes_and_objects.md)| -| 22 | [Web Scraping](./22_Day_Web_scraping/22_web_scraping.md)| -| 23 | [Virtual Environment](./23_Day_Virtual_environment/23_virtual_environment.md)| -| 24 | [Statistics](./24_Day_Statistics/24_statistics.md)| -| 25 | [Pandas](./25_Day_Pandas/25_pandas.md)| -| 26 | [Python web](./26_Day_Python_web/26_python_web.md)| -| 27 | [Python with MongoDB](./27_Day_Python_with_mongodb/27_python_with_mongodb.md)| -| 28 | [API](./28_Day_API/28_API.md)| -| 29 | [Building API](./29_Day_Building_API/29_building_API.md)| -| 30 | [Conclusions](./30_Day_Conclusions/30_conclusions.md)| +| 01 | [Introduction](../readme_ko.md)| +| 02 | [Variables, Built-in Functions](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)| +| 03 | [Operators](../03_Day_Operators/03_operators.md)| +| 04 | [Strings](../04_Day_Strings/04_strings.md)| +| 05 | [Lists](../05_Day_Lists/05_lists.md)| +| 06 | [Tuples](../06_Day_Tuples/06_tuples.md)| +| 07 | [Sets](../07_Day_Sets/07_sets.md)| +| 08 | [Dictionaries](../08_Day_Dictionaries/08_dictionaries.md)| +| 09 | [Conditionals](../09_Day_Conditionals/09_conditionals.md)| +| 10 | [Loops](../10_Day_Loops/10_loops.md)| +| 11 | [Functions](../11_Day_Functions/11_functions.md)| +| 12 | [Modules](../12_Day_Modules/12_modules.md)| +| 13 | [List Comprehension](../13_Day_List_comprehension/13_list_comprehension.md)| +| 14 | [Higher Order Functions](../14_Day_Higher_order_functions/14_higher_order_functions.md)| +| 15 | [Python Type Errors](../15_Day_Python_type_errors/15_python_type_errors.md)| +| 16 | [Python Date time](../16_Day_Python_date_time/16_python_datetime.md) | +| 17 | [Exception Handling](../17_Day_Exception_handling/17_exception_handling.md)| +| 18 | [Regular Expressions](../18_Day_Regular_expressions/18_regular_expressions.md)| +| 19 | [File Handling](../19_Day_File_handling/19_file_handling.md)| +| 20 | [Python Package Manager](../20_Day_Python_package_manager/20_python_package_manager.md)| +| 21 | [Classes and Objects](../21_Day_Classes_and_objects/21_classes_and_objects.md)| +| 22 | [Web Scraping](../22_Day_Web_scraping/22_web_scraping.md)| +| 23 | [Virtual Environment](../23_Day_Virtual_environment/23_virtual_environment.md)| +| 24 | [Statistics](../24_Day_Statistics/24_statistics.md)| +| 25 | [Pandas](../25_Day_Pandas/25_pandas.md)| +| 26 | [Python web](../26_Day_Python_web/26_python_web.md)| +| 27 | [Python with MongoDB](../27_Day_Python_with_mongodb/27_python_with_mongodb.md)| +| 28 | [API](../28_Day_API/28_API.md)| +| 29 | [Building API](../29_Day_Building_API/29_building_API.md)| +| 30 | [Conclusions](../30_Day_Conclusions/30_conclusions.md)| ๐Ÿงก๐Ÿงก๐Ÿงก HAPPY CODING ๐Ÿงก๐Ÿงก๐Ÿงก
Support the author to create more educational materials
-Paypal Logo +Paypal Logo
@@ -56,25 +56,25 @@
-[Day 2 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) +[Day 2 >>](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) -![30DaysOfPython](./images/30DaysOfPython_banner3@2x.png) +![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png) - [๐Ÿ 30 Days Of Python](#-30-days-of-python) - [๐Ÿ“˜ Day 1](#-day-1) - - [ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค](#welcome) - - [์†Œ๊ฐœ](#introduction) - - [์™œ Python์ด๋Š๋ƒ?](#why-python-) - - [ํ™˜๊ฒฝ ์„ค์ •](#environment-setup) - - [Python ์„ค์น˜](#installing-python) - - [Python ์…ธ](#python-shell) - - [Visual Studio Code ์„ค์น˜](#installing-visual-studio-code) - - [visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ](#how-to-use-visual-studio-code) - - [Python ๊ธฐ๋ณธ](#basic-python) - - [Python ๊ตฌ๋ฌธ](#python-syntax) - - [Python ๋“ค์—ฌ์“ฐ๊ธฐ](#python-indentation) - - [์ฃผ์„](#comments) - - [๋ฐ์ดํ„ฐ ํƒ€์ž…](#data-types) + - [ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค](#ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค) + - [์†Œ๊ฐœ](#์†Œ๊ฐœ) + - [์™œ Python์ด๋Š๋ƒ?](#์™œ-python์ด๋Š๋ƒ?) + - [ํ™˜๊ฒฝ ์„ค์ •](#ํ™˜๊ฒฝ-์„ค์ •) + - [Python ์„ค์น˜](#python-์„ค์น˜) + - [Python ์…ธ](#python-์…ธ) + - [Visual Studio Code ์„ค์น˜](#visual-studio-code-์„ค์น˜) + - [visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ](#visual-studio-code๋ฅผ-์‚ฌ์šฉํ•˜๊ธฐ) + - [Python ๊ธฐ๋ณธ](#python-๊ธฐ๋ณธ) + - [Python ๊ตฌ๋ฌธ](#python-๊ตฌ๋ฌธ) + - [Python ๋“ค์—ฌ์“ฐ๊ธฐ](#python-๋“ค์—ฌ์“ฐ๊ธฐ) + - [์ฃผ์„](#์ฃผ์„) + - [๋ฐ์ดํ„ฐ ํƒ€์ž…](#๋ฐ์ดํ„ฐ-ํƒ€์ž…) - [Number](#number) - [String](#string) - [Booleans](#booleans) @@ -82,8 +82,8 @@ - [Dictionary](#dictionary) - [Tuple](#tuple) - [Set](#set) - - [๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ](#checking-data-types) - - [Python ํŒŒ์ผ](#python-file) + - [๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ](#๋ฐ์ดํ„ฐ-ํƒ€์ž…-์ฒดํฌ) + - [Python ํŒŒ์ผ](#python-ํŒŒ์ผ) - [๐Ÿ’ป Exercises - Day 1](#-exercises---day-1) - [Exercise: Level 1](#exercise-level-1) - [Exercise: Level 2](#exercise-level-2) @@ -119,7 +119,7 @@ Windows ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ macOS ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. -[![Windows์—์„œ ์„ค์น˜](./images/installing_on_windows.png)](https://www.python.org/) +[![Windows์—์„œ ์„ค์น˜](../images/installing_on_windows.png)](https://www.python.org/) Python์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ์žฅ์น˜ ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค. @@ -127,7 +127,7 @@ Python์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ์žฅ์น˜ ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช… python --version ``` -![Python Version](./images/python_versio.png) +![Python Version](../images/python_versio.png) ํ„ฐ๋ฏธ๋„์—์„œ ๋ณด์‹œ๋‹ค์‹œํ”ผ ์ €๋Š” ํ˜„์žฌ _Python 3.7.5_ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ Python ๋ฒ„์ „์€ ๋‚ด ๋ฒ„์ „๊ณผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์ง€๋งŒ 3.6 ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python ๋ฒ„์ „์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ž˜ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์ปดํ“จํ„ฐ์— Python์ด ์„ค์น˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์„น์…˜์œผ๋กœ ๊ณ„์† ์ง„ํ–‰ํ•˜์‹ญ์‹œ์˜ค. @@ -142,35 +142,35 @@ Python Shell์€ ์‚ฌ์šฉ์ž์˜ Python ์ฝ”๋“œ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅ python ``` -![Python Scripting Shell](./images/opening_python_shell.png) +![Python Scripting Shell](../images/opening_python_shell.png) Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฌ๊ณ  Python ์ฝ”๋“œ(Python ์Šคํฌ๋ฆฝํŠธ)๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ๊ธฐํ˜ธ >>> ์˜†์— Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  Enter๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. Python ์Šคํฌ๋ฆฝํŒ… ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. -![Python script on Python shell](./images/adding_on_python_shell.png) +![Python script on Python shell](../images/adding_on_python_shell.png) ํ›Œ๋ฅญํ•ฉ๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์–ด๋–ป๊ฒŒ ๋‹ซ์Šต๋‹ˆ๊นŒ? ์…ธ์„ ๋‹ซ์œผ๋ ค๋ฉด ๊ธฐํ˜ธ ์˜†์— >> **exit()** ๋ช…๋ น์„ ์ž‘์„ฑํ•˜๊ณ  Enter ํ‚ค๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. -![Exit from python shell](./images/exit_from_shell.png) +![Exit from python shell](../images/exit_from_shell.png) ์ด์ œ Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ฌ๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•˜์Šต๋‹ˆ๋‹ค. Python์€ Python์ด ์ดํ•ดํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ณ ์˜์ ์ธ ์‹ค์ˆ˜๋ฅผ ํ•˜๊ณ  Python์ด ๋ฌด์—‡์„ ๋ฐ˜ํ™˜ํ•˜๋Š”์ง€ ๋ด…์‹œ๋‹ค. -![Invalid Syntax Error](./images/invalid_syntax_error.png) +![Invalid Syntax Error](../images/invalid_syntax_error.png) ๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด Python์€ ์šฐ๋ฆฌ๊ฐ€ ์ €์ง€๋ฅธ ์‹ค์ˆ˜์™€ _Syntax Error: invalid syntax_๋ฅผ ์•Œ๊ณ  ์žˆ์„ ์ •๋„๋กœ ์˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. Python์—์„œ x๋ฅผ ๊ณฑ์…ˆ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ (x)๊ฐ€ Python์—์„œ ์œ ํšจํ•œ ๊ตฌ๋ฌธ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. (**x**) ๋Œ€์‹  ๊ณฑ์…ˆ์— ๋ณ„ํ‘œ(*)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜๋Š” ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์—์„œ ์˜ค๋ฅ˜๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์ œ๊ฑฐํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ *๋””๋ฒ„๊น…*์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. **x** ๋Œ€์‹  *๋ฅผ ๋„ฃ์–ด ๋””๋ฒ„๊น…ํ•ด ๋ด…์‹œ๋‹ค. -![Fixing Syntax Error](./images/fixing_syntax_error.png) +![Fixing Syntax Error](../images/fixing_syntax_error.png) ๋ฒ„๊ทธ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ๊ณ  ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋˜์—ˆ์œผ๋ฉฐ ์˜ˆ์ƒํ–ˆ๋˜ ๊ฒฐ๊ณผ๋ฅผ ์–ป์—ˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ๋กœ์„œ ๋งค์ผ ์ด๋Ÿฌํ•œ ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๋ฅผ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•์„ ์•„๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋””๋ฒ„๊น…์„ ์ž˜ํ•˜๋ ค๋ฉด ์–ด๋–ค ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์ดํ•ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” Python ์˜ค๋ฅ˜ ์ค‘ ์ผ๋ถ€๋Š” *SyntaxError*, *IndexError*, *NameError*, *ModuleNotFoundError*, *KeyError*, *ImportError*, *AttributeError*, *TypeError*, *ValueError*, *ZeroDivisionError* ๋“ฑ์ž…๋‹ˆ๋‹ค. ์ดํ›„ ์„น์…˜์—์„œ ๋‹ค๋ฅธ Python **_์˜ค๋ฅ˜ ์œ ํ˜•_**์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋” ์—ฐ์Šตํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋™ํ•˜์—ฌ **python**์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์”๋‹ˆ๋‹ค. -![Python Scripting Shell](./images/opening_python_shell.png) +![Python Scripting Shell](../images/opening_python_shell.png) Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฝ๋‹ˆ๋‹ค. ๋ช‡ ๊ฐ€์ง€ ๊ธฐ๋ณธ์ ์ธ ์ˆ˜ํ•™ ์—ฐ์‚ฐ(๋”ํ•˜๊ธฐ, ๋นผ๊ธฐ, ๊ณฑํ•˜๊ธฐ, ๋‚˜๋ˆ„๊ธฐ, ๋‚˜๋จธ์ง€, ์ง€์ˆ˜)์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. @@ -197,17 +197,17 @@ _comment_๋Š” Python์— ์˜ํ•ด ์‹คํ–‰๋˜์ง€ ์•Š๋Š” ์ฝ”๋“œ์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค. ๋”ฐ # (#) ์‹ฌ๋ณผ๋กœ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์€ ํŒŒ์ด์ฌ ์ฃผ์„์ž…๋‹ˆ๋‹ค. ``` -![Maths on python shell](./images/maths_on_python_shell.png) +![Maths on python shell](../images/maths_on_python_shell.png) ๋‹ค์Œ ์„น์…˜์œผ๋กœ ์ด๋™ํ•˜๊ธฐ ์ „์— Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ๋” ๋งŽ์€ ์—ฐ์Šต์„ ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์…ธ์—์„œ _exit()_๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์—ด๋ฆฐ ์…ธ์„ ๋‹ซ์•˜๋‹ค๊ฐ€ ๋‹ค์‹œ ์—ด์–ด Python ์…ธ์—์„œ ํ…์ŠคํŠธ๋ฅผ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์„ ์—ฐ์Šตํ•ด ๋ด…์‹œ๋‹ค. -![Writing String on python shell](./images/writing_string_on_shell.png) +![Writing String on python shell](../images/writing_string_on_shell.png) ### Visual Studio Code ์„ค์น˜ Python ๋Œ€ํ™”ํ˜• ์…ธ์€ ์ž‘์€ ์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์‹œ๋„ํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•˜๋Š” ๋ฐ ์ ํ•ฉํ•˜์ง€๋งŒ ํฐ ํ”„๋กœ์ ํŠธ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์ž‘์—… ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ์ž๋Š” ๋‹ค์–‘ํ•œ ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Visual Studio Code๋Š” ๋งค์šฐ ์ธ๊ธฐ ์žˆ๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ…์ŠคํŠธ ํŽธ์ง‘๊ธฐ์ž…๋‹ˆ๋‹ค. ๋‚˜๋Š” vscode์˜ ํŒฌ์ด๊ณ  Visual Studio ์ฝ”๋“œ๋ฅผ [๋‹ค์šด๋กœ๋“œ](https://code.visualstudio.com/)ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•˜๊ณ  ์‹ถ์ง€๋งŒ, ๋‹ค๋ฅธ ํŽธ์ง‘์ž๋ฅผ ์„ ํ˜ธํ•œ๋‹ค๋ฉด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์ž์œ ๋กญ๊ฒŒ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค. -[![Visual Studio Code](./images/vscode.png)](https://code.visualstudio.com/) +[![Visual Studio Code](../images/vscode.png)](https://code.visualstudio.com/) Visual Studio Code๋ฅผ ์„ค์น˜ํ•˜์…จ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋น„๋””์˜ค๋ฅผ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ Python์šฉ Visual Studio Code[๋น„๋””์˜ค ์ž์Šต์„œ](https://www.youtube.com/watch?v=bn7Cx4z-vSo)๋ฅผ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. @@ -216,21 +216,21 @@ Visual Studio Code๋ฅผ ์„ค์น˜ํ•˜์…จ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ฒ  Visual Studio ์•„์ด์ฝ˜์„ ๋‘ ๋ฒˆ ํด๋ฆญํ•˜์—ฌ Visual Studio ์ฝ”๋“œ๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ์—ด๋ฉด ์ด๋Ÿฐ ์ข…๋ฅ˜์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋ ˆ์ด๋ธ”์ด ์ง€์ •๋œ ์•„์ด์ฝ˜์„ ๋”ฐ๋ผํ•ด๋ณด์„ธ์š”. -![Visual studio Code](./images/vscode_ui.png) +![Visual studio Code](../images/vscode_ui.png) ๋ฐ”ํƒ• ํ™”๋ฉด์— 30DaysOfPython์ด๋ผ๋Š” ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฝ์‹œ๋‹ค. -![Opening Project on Visual studio](./images/how_to_open_project_on_vscode.png) +![Opening Project on Visual studio](../images/how_to_open_project_on_vscode.png) -![Opening a project](./images/opening_project.png) +![Opening a project](../images/opening_project.png) ํŒŒ์ผ์„ ์—ด๋ฉด 30DaysOfPython ํ”„๋กœ์ ํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์— ํŒŒ์ผ๊ณผ ํด๋”๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด ์ฒซ ๋ฒˆ์งธ ํŒŒ์ผ์ธ helloworld.py๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ๋„ ๋˜‘๊ฐ™์ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. -![Creating a python file](./images/helloworld.png) +![Creating a python file](../images/helloworld.png) ํ•˜๋ฃจ๋™์•ˆ ์˜ค๋ž˜ ์ฝ”๋”ฉ์„ ํ•œ ํ›„์— ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ๋‹ซ๊ณ  ์‹ถ์Šต๋‹ˆ๊นŒ? ์ด๋ ‡๊ฒŒ ์—ด๋ฆฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ซ์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. -![Closing project](./images/closing_opened_project.png) +![Closing project](../images/closing_opened_project.png) ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ •์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์„ ์‹œ์ž‘ํ•ด ๋ด…์‹œ๋‹ค. @@ -244,7 +244,7 @@ Python ์Šคํฌ๋ฆฝํŠธ๋Š” Python ๋Œ€ํ™”ํ˜• ์…ธ ๋˜๋Š” ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ์—์„œ ์ž‘์„ฑ ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ํ…์ŠคํŠธ์˜ ๊ณต๋ฐฑ์ž…๋‹ˆ๋‹ค. ๋งŽ์€ ์–ธ์–ด์—์„œ ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ Python์€ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ๋Š” ์ค‘๊ด„ํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋“ค์—ฌ์“ฐ๊ธฐ ๋Œ€์‹  ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. Python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ๋ฒ„๊ทธ ์ค‘ ํ•˜๋‚˜๋Š” ์ž˜๋ชป๋œ ๋“ค์—ฌ์“ฐ๊ธฐ์ž…๋‹ˆ๋‹ค. -![Indentation Error](./images/indentation.png) +![Indentation Error](../images/indentation.png) ### ์ฃผ์„ @@ -372,7 +372,7 @@ Python ์‚ฌ์ „ ๊ฐœ์ฒด๋Š” ํ‚ค ๊ฐ’ ์Œ ํ˜•์‹์˜ ์ •๋ ฌ๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ ๋ชจ ํŠน์ • ๋ฐ์ดํ„ฐ/๋ณ€์ˆ˜์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด **type** ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์–‘ํ•œ Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: -![Checking Data types](./images/checking_data_types.png) +![Checking Data types](../images/checking_data_types.png) ### Python ํŒŒ์ผ @@ -408,7 +408,7 @@ print(type((9.8, 3.14, 2.7))) # Tuple Python ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ ค๋ฉด ์•„๋ž˜ ์ด๋ฏธ์ง€๋ฅผ ํ™•์ธํ•˜์„ธ์š”. Visual Studio Code์—์„œ ๋…น์ƒ‰ ๋ฒ„ํŠผ์„ ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜ ํ„ฐ๋ฏธ๋„์— *python helloworld.py*๋ฅผ ์ž…๋ ฅํ•˜์—ฌ Python ํŒŒ์ผ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. -![Running python script](./images/running_python_script.png) +![Running python script](../images/running_python_script.png) ๐ŸŒ• ์ข‹์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 1์ผ์ฐจ ๋„์ „์„ ์™„๋ฃŒํ–ˆ๊ณ  ๋‹น์‹ ์€ ์œ„๋Œ€ํ•œ ์—ฌ์ •์— ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•ด๋ด…์‹œ๋‹ค. @@ -451,4 +451,4 @@ Python ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ ค๋ฉด ์•„๋ž˜ ์ด๋ฏธ์ง€๋ฅผ ํ™•์ธํ•˜์„ธ์š”. Visual Stu ๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค ! ๐ŸŽ‰ -[Day 2 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) \ No newline at end of file +[Day 2 >>](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) \ No newline at end of file From 54af60ae4bc16430254fcfb961e2d3ce3abee55e Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Thu, 8 Dec 2022 13:15:32 +0900 Subject: [PATCH 3/8] lang ko --- lang-ko/readme_ko.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang-ko/readme_ko.md b/lang-ko/readme_ko.md index 558efe95..bc628609 100644 --- a/lang-ko/readme_ko.md +++ b/lang-ko/readme_ko.md @@ -2,7 +2,7 @@ |# Day | Topics | |------|:---------------------------------------------------------:| -| 01 | [Introduction](../readme_ko.md)| +| 01 | [Introduction](./readme_ko.md)| | 02 | [Variables, Built-in Functions](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)| | 03 | [Operators](../03_Day_Operators/03_operators.md)| | 04 | [Strings](../04_Day_Strings/04_strings.md)| From 2929ed04cd8a4aae68969846954e452f0ac6b2a8 Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Fri, 9 Dec 2022 10:27:16 +0900 Subject: [PATCH 4/8] kor ver --- Korean/04_strings_ko.md | 591 ++++++++++++++++++++++++++++++++++++++++ Korean/readme_ko.md | 454 ++++++++++++++++++++++++++++++ 2 files changed, 1045 insertions(+) create mode 100644 Korean/04_strings_ko.md create mode 100644 Korean/readme_ko.md diff --git a/Korean/04_strings_ko.md b/Korean/04_strings_ko.md new file mode 100644 index 00000000..b2d92dee --- /dev/null +++ b/Korean/04_strings_ko.md @@ -0,0 +1,591 @@ +
+ 30 Days Of Python: Day 4 - Strings Twitter Follow +
+

Author: Asabeneh Yetayeh
Second Edition: July, 2021

+
+ +[<< Day 3](../03_Day_Operators/03_operators.md) | [Day 5 >>](../05_Day_Lists/05_lists.md) + +![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png) + +- [Day 4](#day-4) + - [๋ฌธ์ž์—ด](#strings) + - [๋ฌธ์ž์—ด ๋งŒ๋“ค๊ธฐ](#creating-a-string) + - [๋ฌธ์ž์—ด ์—ฐ๊ฒฐ](#string-concatenation) + - [๋ฌธ์ž์—ด์˜ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค](#escape-sequences-in-strings) + - [๋ฌธ์ž์—ด ํฌ๋งคํŒ…](#string-formatting) + - [์˜ฌ๋“œ ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํฌ๋งคํŒ…(% ์—ฐ์‚ฐ์ž)](#old-style-string-formatting--operator) + - [์ƒˆ๋กœ์šด ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํฌ๋งคํŒ…(str.format)](#new-style-string-formatting-strformat) + - [๋ฌธ์ž์—ด Interpolation / f-Strings (Python 3.6+)](#string-interpolation--f-strings-python-36) + - [๋ฌธ์ž ์‹œํ€€์Šค๋กœ์„œ์˜ Python ๋ฌธ์ž์—ด](#python-strings-as-sequences-of-characters) + - [์–ธํŒจํ‚น ๋ฌธ์ž](#unpacking-characters) + - [์ธ๋ฑ์Šค๋กœ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž์— ์•ก์„ธ์Šค](#accessing-characters-in-strings-by-index) + - [ํŒŒ์ด์ฌ ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑ](#slicing-python-strings) + - [๋ฌธ์ž์—ด ๋ฆฌ๋ฒ„์Šค](#reversing-a-string) + - [์Šฌ๋ผ์ด์‹ฑํ•˜๋Š” ๋™์•ˆ ๋ฌธ์ž ๊ฑด๋„ˆ๋›ฐ๊ธฐ](#skipping-characters-while-slicing) + - [๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ](#string-methods) + - [๐Ÿ’ป Exercises - Day 4](#-exercises---day-4) + +# Day 4 + +## ๋ฌธ์ž์—ด + +ํ…์ŠคํŠธ๋Š” ๋ฌธ์ž์—ด ๋ฐ์ดํ„ฐ ์œ ํ˜•์ž…๋‹ˆ๋‹ค. ํ…์ŠคํŠธ๋กœ ์ž‘์„ฑ๋œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ ๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค. ์ž‘์€๋”ฐ์˜ดํ‘œ, ํฐ๋”ฐ์˜ดํ‘œ ๋˜๋Š” ์‚ผ์ค‘๋”ฐ์˜ดํ‘œ ์•„๋ž˜์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋Š” ๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋‹ค์–‘ํ•œ ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ์™€ ๋‚ด์žฅ ํ•จ์ˆ˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด len() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์‹ญ์‹œ์˜ค. + +### ๋ฌธ์ž์—ด ๋งŒ๋“ค๊ธฐ + +```py +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be made using a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of Python Challenge" +print(sentence) +``` + +์—ฌ๋Ÿฌ ์ค„ ๋ฌธ์ž์—ด์€ ์„ธ ๊ฐœ์˜ ์ž‘์€๋”ฐ์˜ดํ‘œ(''') ๋˜๋Š” ์„ธ ๊ฐœ์˜ ํฐ๋”ฐ์˜ดํ‘œ(""")๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. + +```py +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) + +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) +``` + +### ๋ฌธ์ž์—ด ์—ฐ๊ฒฐ + +๋ฌธ์ž์—ด์„ ํ•จ๊ป˜ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์„ ๋ณ‘ํ•ฉํ•˜๊ฑฐ๋‚˜ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฒƒ์„ ์—ฐ๊ฒฐ์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. + +```py +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking the length of a string using len() built-in function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 16 +``` + +### ๋ฌธ์ž์—ด์˜ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค + +Python ๋ฐ ๊ธฐํƒ€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ \ ๋‹ค์Œ์— ์˜ค๋Š” ๋ฌธ์ž๋Š” ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค์ž…๋‹ˆ๋‹ค. ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ธ ์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + +- \n: ์ƒˆ๋กœ์šด ๋ผ์ธ +- \t: ํƒญ์€(8์นธ)์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. +- \\: ๋ฐฑ์Šฌ๋ž˜์‹œ +- \': ์ž‘์€๋”ฐ์˜ดํ‘œ(') +- \": ํฐ๋”ฐ์˜ดํ‘œ(") + +์ด์ œ ์œ„์˜ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค๋ฅผ ์˜ˆ์ œ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + +```py +print('I hope everyone is enjoying the Python Challenge.\nAre you ?') # line break +print('Days\tTopics\tExercises') # adding tab space or 4 spaces +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a backslash symbol (\\)') # To write a backslash +print('In every programming language it starts with \"Hello, World!\"') # to write a double quote inside a single quote + +# output +I hope every one is enjoying the Python Challenge. +Are you ? +Days Topics Exercises +Day 1 5 5 +Day 2 6 20 +Day 3 5 23 +Day 4 1 35 +This is a backslash symbol (\) +In every programming language it starts with "Hello, World!" +``` + +### ๋ฌธ์ž์—ด ํฌ๋งคํŒ… + +#### ์˜ฌ๋“œ ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํ˜•์‹ํ™”(% ์—ฐ์‚ฐ์ž) + +Python์—๋Š” ๋ฌธ์ž์—ด ํ˜•์‹์„ ์ง€์ •ํ•˜๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์„น์…˜์—์„œ๋Š” ๊ทธ ์ค‘ ์ผ๋ถ€๋ฅผ ๋‹ค๋ฃฐ ๊ฒƒ์ž…๋‹ˆ๋‹ค. "%" ์—ฐ์‚ฐ์ž๋Š” "์ธ์ˆ˜ ์ง€์ •์ž", "%s"์™€ ๊ฐ™์€ ํŠน์ˆ˜ ๊ธฐํ˜ธ์™€ ํ•จ๊ป˜ ์ผ๋ฐ˜ ํ…์ŠคํŠธ๋ฅผ ํฌํ•จํ•˜๋Š” ํ˜•์‹ ๋ฌธ์ž์—ด๊ณผ ํ•จ๊ป˜ "ํŠœํ”Œ"(๊ณ ์ • ํฌ๊ธฐ ๋ชฉ๋ก)๋กœ ๋ฌถ์ธ ๋ณ€์ˆ˜ ์„ธํŠธ์˜ ํ˜•์‹์„ ์ง€์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. , "%d", "%f", "%. ์ž๋ฆฟ์ˆ˜ f". + +- %s - ๋ฌธ์ž์—ด(๋˜๋Š” ์ˆซ์ž์™€ ๊ฐ™์€ ๋ฌธ์ž์—ด ํ‘œํ˜„์ด ์žˆ๋Š” ๋ชจ๋“  ๊ฐ์ฒด) +- %d - ์ •์ˆ˜ +- %f - ๋ถ€๋™ ์†Œ์ˆ˜์  ์ˆซ์ž +- "%. number of digits f" - ์ •๋ฐ€๋„๊ฐ€ ๊ณ ์ •๋œ ๋ถ€๋™ ์†Œ์ˆ˜์  ์ˆซ์ž + +```py +# Strings only +first_name = 'Asabeneh' +last_name = 'Yetayeh' +language = 'Python' +formated_string = 'I am %s %s. I teach %s' %(first_name, last_name, language) +print(formated_string) + +# Strings and numbers +radius = 10 +pi = 3.14 +area = pi * radius ** 2 +formated_string = 'The area of circle with a radius %d is %.2f.' %(radius, area) # 2 refers the 2 significant digits after the point + +python_libraries = ['Django', 'Flask', 'NumPy', 'Matplotlib','Pandas'] +formated_string = 'The following are python libraries:%s' % (python_libraries) +print(formated_string) # "The following are python libraries:['Django', 'Flask', 'NumPy', 'Matplotlib','Pandas']" +``` + +#### ์ƒˆ๋กœ์šด์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํ˜•์‹ํ™”(str.format) + +์ด ํ˜•์‹์€ Python ๋ฒ„์ „ 3์—์„œ ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. + +```py + +first_name = 'Asabeneh' +last_name = 'Yetayeh' +language = 'Python' +formated_string = 'I am {} {}. I teach {}'.format(first_name, last_name, language) +print(formated_string) +a = 4 +b = 3 + +print('{} + {} = {}'.format(a, b, a + b)) +print('{} - {} = {}'.format(a, b, a - b)) +print('{} * {} = {}'.format(a, b, a * b)) +print('{} / {} = {:.2f}'.format(a, b, a / b)) # limits it to two digits after decimal +print('{} % {} = {}'.format(a, b, a % b)) +print('{} // {} = {}'.format(a, b, a // b)) +print('{} ** {} = {}'.format(a, b, a ** b)) + +# output +4 + 3 = 7 +4 - 3 = 1 +4 * 3 = 12 +4 / 3 = 1.33 +4 % 3 = 1 +4 // 3 = 1 +4 ** 3 = 64 + +# Strings and numbers +radius = 10 +pi = 3.14 +area = pi * radius ** 2 +formated_string = 'The area of a circle with a radius {} is {:.2f}.'.format(radius, area) # 2 digits after decimal +print(formated_string) + +``` + +#### ๋ฌธ์ž์—ด Interpolation / f-Strings (Python 3.6+) + +๋˜ ๋‹ค๋ฅธ ์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด ํ˜•์‹ํ™”๋Š” ๋ฌธ์ž์—ด ๋ณด๊ฐ„๋ฒ•์ธ f-๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ f๋กœ ์‹œ์ž‘ํ•˜๊ณ  ํ•ด๋‹น ์œ„์น˜์— ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py +a = 4 +b = 3 +print(f'{a} + {b} = {a +b}') +print(f'{a} - {b} = {a - b}') +print(f'{a} * {b} = {a * b}') +print(f'{a} / {b} = {a / b:.2f}') +print(f'{a} % {b} = {a % b}') +print(f'{a} // {b} = {a // b}') +print(f'{a} ** {b} = {a ** b}') +``` + +### ๋ฌธ์ž ์‹œํ€€์Šค๋กœ์„œ์˜ Python ๋ฌธ์ž์—ด + +Python ๋ฌธ์ž์—ด์€ ๋ฌธ์ž ์‹œํ€€์Šค์ด๋ฉฐ, ๊ธฐ๋ณธ ์•ก์„ธ์Šค ๋ฐฉ๋ฒ•์„ ๋‹ค๋ฅธ Python ์ˆœ์„œ ๊ฐ์ฒด ์‹œํ€€์Šค(๋ชฉ๋ก ๋ฐ ํŠœํ”Œ)์™€ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด(๋ฐ ๋ชจ๋“  ์‹œํ€€์Šค์˜ ๊ฐœ๋ณ„ ๋ฉค๋ฒ„)์—์„œ ๋‹จ์ผ ๋ฌธ์ž๋ฅผ ์ถ”์ถœํ•˜๋Š” ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ ํ•ด๋‹น ๋ณ€์ˆ˜๋กœ ์••์ถ•์„ ํ‘ธ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. + +#### ์–ธํŒจํ‚น ๋ฌธ์ž + +``` +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n +``` + +#### ์ธ๋ฑ์Šค๋กœ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž์— ์•ก์„ธ์Šค + +ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ์นด์šดํŒ…์€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋ฌธ์ž์—ด์˜ ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ž๋Š” ์ธ๋ฑ์Šค๊ฐ€ 0์ด๊ณ  ๋ฌธ์ž์—ด์˜ ๋งˆ์ง€๋ง‰ ๋ฌธ์ž๋Š” ๋ฌธ์ž์—ด์˜ ๊ธธ์ด์—์„œ 1์„ ๋บ€ ๊ฐ’์ž…๋‹ˆ๋‹ค. + +![String index](../images/string_index.png) + +```py +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n +``` + +์˜ค๋ฅธ์ชฝ ๋์—์„œ ์‹œ์ž‘ํ•˜๋ ค๋ฉด ์Œ์ˆ˜ ์ธ๋ฑ์‹ฑ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. -1์€ ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค์ž…๋‹ˆ๋‹ค. + +```py +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o +``` + +#### ํŒŒ์ด์ฌ ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑ + +ํŒŒ์ด์ฌ์—์„œ๋Š” ๋ฌธ์ž์—ด์„ ํ•˜์œ„ ๋ฌธ์ž์—ด๋กœ ์Šฌ๋ผ์ด์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +print(first_three) #Pyt +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon +``` + +#### ๋ฌธ์ž์—ด ๋ฆฌ๋ฒ„์Šค + +ํŒŒ์ด์ฌ์—์„œ ๋ฌธ์ž์—ด์„ ์‰ฝ๊ฒŒ ๋’ค์ง‘์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py +greeting = 'Hello, World!' +print(greeting[::-1]) # !dlroW ,olleH +``` + +#### ์Šฌ๋ผ์ด์‹ฑํ•˜๋Š” ๋™์•ˆ ๋ฌธ์ž ๊ฑด๋„ˆ๋›ฐ๊ธฐ + +์Šฌ๋ผ์ด์Šค ๋ฉ”์†Œ๋“œ์— ๋‹จ๊ณ„ ์ธ์ˆ˜๋ฅผ ์ „๋‹ฌํ•˜์—ฌ ์Šฌ๋ผ์ด์Šคํ•˜๋Š” ๋™์•ˆ ๋ฌธ์ž๋ฅผ ๊ฑด๋„ˆ๋›ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py +language = 'Python' +pto = language[0:6:2] # +print(pto) # Pto +``` + +### ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ + +๋ฌธ์ž์—ด์„ ํ˜•์‹ํ™”ํ•  ์ˆ˜ ์žˆ๋Š” ๋งŽ์€ ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์˜ˆ์ œ์—์„œ ์ผ๋ถ€ ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. + +- capitalize(): ๋ฌธ์ž์—ด์˜ ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜ + +```py +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' +``` + +- count(): ๋ฌธ์ž์—ด์—์„œ ํ•˜์œ„ ๋ฌธ์ž์—ด์˜ ๋ฐœ์ƒ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. count(substring, start=.., end=..). ์‹œ์ž‘์€ ์นด์šดํŠธ๋ฅผ ์œ„ํ•œ ์‹œ์ž‘ ์ธ๋ฑ์‹ฑ์ด๊ณ  ๋์€ ์นด์šดํŠธํ•  ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค์ž…๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1, +print(challenge.count('th')) # 2` +``` + +- endswith(): ๋ฌธ์ž์—ด์ด ์ง€์ •๋œ ๋์œผ๋กœ ๋๋‚˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False +``` + +- expandtabs(): ํƒญ ๋ฌธ์ž๋ฅผ ๊ณต๋ฐฑ์œผ๋กœ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ํƒญ ํฌ๊ธฐ๋Š” 8์ž…๋‹ˆ๋‹ค. ํƒญ ํฌ๊ธฐ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' +``` + +- find(): ํ•˜์œ„ ๋ฌธ์ž์—ด์ด ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ฐพ์„ ์ˆ˜ ์—†์œผ๋ฉด -1์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1, +print(challenge.count('th')) # 2` +``` + +- rfind(): ํ•˜์œ„ ๋ฌธ์ž์—ด์ด ๋งˆ์ง€๋ง‰์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ฐพ์„ ์ˆ˜ ์—†์œผ๋ฉด -1์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.rfind('y')) # 5 +print(challenge.rfind('th')) # 1 +``` + +- format(): ๋ฌธ์ž์—ด์„ ๋” ๋‚˜์€ ์ถœ๋ ฅ์œผ๋กœ ํฌ๋งทํ•ฉ๋‹ˆ๋‹ค.
๋ฌธ์ž์—ด ํ˜•์‹์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์ด [๋งํฌ](https://www.programiz.com/python-programming/methods/string/format) ๋ฅผ ํ™•์ธํ•˜์„ธ์š”. + +```py +first_name = 'Asabeneh' +last_name = 'Yetayeh' +age = 250 +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I am {} years old. I live in {}.'.format(first_name, last_name, age, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am 250 years old. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi * radius ** 2 +result = 'The area of a circle with radius {} is {}'.format(str(radius), str(area)) +print(result) # The area of a circle with radius 10 is 314 +``` + +- index(): ํ•˜์œ„ ๋ฌธ์ž์—ด์˜ ๊ฐ€์žฅ ๋‚ฎ์€ ์ƒ‰์ธ์„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์ถ”๊ฐ€ ์ธ์ˆ˜๋Š” ์‹œ์ž‘ ๋ฐ ๋ ์ƒ‰์ธ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค(๊ธฐ๋ณธ๊ฐ’ 0 ๋ฐ ๋ฌธ์ž์—ด ๊ธธ์ด - 1). ํ•˜์œ„ ๋ฌธ์ž์—ด์„ ์ฐพ์„ ์ˆ˜ ์—†์œผ๋ฉด valueError๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +sub_string = 'da' +print(challenge.index(sub_string)) # 7 +print(challenge.index(sub_string, 9)) # error +``` + +- rindex(): ํ•˜์œ„ ๋ฌธ์ž์—ด์˜ ๊ฐ€์žฅ ๋†’์€ ์ƒ‰์ธ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ์ธ์ˆ˜๋Š” ์‹œ์ž‘ ๋ฐ ๋ ์ƒ‰์ธ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค(๊ธฐ๋ณธ๊ฐ’ 0 ๋ฐ ๋ฌธ์ž์—ด ๊ธธ์ด - 1). + +```py +challenge = 'thirty days of python' +sub_string = 'da' +print(challenge.rindex(sub_string)) # 8 +print(challenge.rindex(sub_string, 9)) # error +``` + +- isalnum(): ์˜์ˆซ์ž ํ™•์ธ + +```py +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False, space is not an alphanumeric character + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False +``` + +- isalpha(): ๋ชจ๋“  ๋ฌธ์ž์—ด ์š”์†Œ๊ฐ€ ์•ŒํŒŒ๋ฒณ ๋ฌธ์ž(az ๋ฐ AZ)์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.isalpha()) # False, space is once again excluded +challenge = 'ThirtyDaysPython' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False +``` + +- isdecimal(): ๋ฌธ์ž์—ด์˜ ๋ชจ๋“  ๋ฌธ์ž๊ฐ€ ์‹ญ์ง„์ˆ˜(0-9)์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.isdecimal()) # False +challenge = '123' +print(challenge.isdecimal()) # True +challenge = '\u00B2' +print(challenge.isdigit()) # False +challenge = '12 3' +print(challenge.isdecimal()) # False, space not allowed +``` + +- isdigit(): ๋ฌธ์ž์—ด์˜ ๋ชจ๋“  ๋ฌธ์ž๊ฐ€ ์ˆซ์ž์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค(์ˆซ์ž๋Š” 0-9 ๋ฐ ์ผ๋ถ€ ๋‹ค๋ฅธ ์œ ๋‹ˆ์ฝ”๋“œ ๋ฌธ์ž). + +```py +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True +challenge = '\u00B2' +print(challenge.isdigit()) # True +``` + +- isnumeric(): ๋ฌธ์ž์—ด์˜ ๋ชจ๋“  ๋ฌธ์ž๊ฐ€ ์ˆซ์ž์ธ์ง€ ๋˜๋Š” ์ˆซ์ž์™€ ๊ด€๋ จ๋œ ๊ฒƒ์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค(isdigit()์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ยฝ๊ณผ ๊ฐ™์€ ๋” ๋งŽ์€ ๊ธฐํ˜ธ๋ฅผ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค). + +```py +num = '10' +print(num.isnumeric()) # True +num = '\u00BD' # ยฝ +print(num.isnumeric()) # True +num = '10.5' +print(num.isnumeric()) # False +``` + +- isidentifier(): ์œ ํšจํ•œ ์‹๋ณ„์ž๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์ด ์œ ํšจํ•œ ๋ณ€์ˆ˜ ์ด๋ฆ„์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True +``` + +- islower(): ๋ฌธ์ž์—ด์˜ ๋ชจ๋“  ์•ŒํŒŒ๋ฒณ ๋ฌธ์ž๊ฐ€ ์†Œ๋ฌธ์ž์ธ์ง€ ํ™•์ธ + +```py +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False +``` + +- islower(): ๋ฌธ์ž์—ด์˜ ๋ชจ๋“  ์•ŒํŒŒ๋ฒณ ๋ฌธ์ž๊ฐ€ ์†Œ๋ฌธ์ž์ธ์ง€ ํ™•์ธ + +```py +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True +``` + +- join(): ์—ฐ๊ฒฐ๋œ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +```py +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = ' '.join(web_tech) +print(result) # 'HTML CSS JavaScript React' +``` + +```py +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '# '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' +``` + +- strip(): ๋ฌธ์ž์—ด์˜ ์‹œ์ž‘๊ณผ ๋์—์„œ ์‹œ์ž‘ํ•˜์—ฌ ์ฃผ์–ด์ง„ ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of pythoonnn' +print(challenge.strip('noth')) # 'irty days of py' +``` + +- replace(): ํ•˜์œ„ ๋ฌธ์ž์—ด์„ ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด๋กœ ๋Œ€์ฒดํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' +``` + +- split(): ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด ๋˜๋Š” ๊ณต๋ฐฑ์„ ๊ตฌ๋ถ„ ๊ธฐํ˜ธ๋กœ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ž์—ด์„ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] +challenge = 'thirty, days, of, python' +print(challenge.split(', ')) # ['thirty', 'days', 'of', 'python'] +``` + +- title(): ์ œ๋ชฉ ์ผ€์ด์Šค ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +```py +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python +``` + +- swapcase(): ๋ชจ๋“  ๋Œ€๋ฌธ์ž๋ฅผ ์†Œ๋ฌธ์ž๋กœ, ๋ชจ๋“  ์†Œ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜ + +```py +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON +``` + +- startswith(): ๋ฌธ์ž์—ด์ด ์ง€์ •๋œ ๋ฌธ์ž์—ด๋กœ ์‹œ์ž‘ํ•˜๋Š”์ง€ ํ™•์ธ + +```py +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True + +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False +``` + +๐ŸŒ• ๋‹น์‹ ์€ ํŠน๋ณ„ํ•œ ์‚ฌ๋žŒ์ด๊ณ  ๋†€๋ผ์šด ์ž ์žฌ๋ ฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 4์ผ ์ฐจ ๋„์ „์„ ์™„๋ฃŒํ–ˆ๊ณ  ๋‹น์‹ ์€ ์œ„๋Œ€ํ•จ์„ ํ–ฅํ•œ ๋‹น์‹ ์˜ ๊ธธ์— 4๊ฑธ์Œ ๋‚จ์•˜์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•˜์‹ญ์‹œ์˜ค. + +## ๐Ÿ’ป Exercises - Day 4 + +1. ๋ฌธ์ž์—ด 'Thirty', 'Days', 'Of', 'Python'์„ ๋‹จ์ผ ๋ฌธ์ž์—ด 'Thirty Days Of Python'์— ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. +2. ๋ฌธ์ž์—ด 'Coding', 'For' , 'All'์„ ๋‹จ์ผ ๋ฌธ์ž์—ด 'Coding For All'์— ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. +3. company๋ผ๋Š” ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๊ณ  ์ดˆ๊ธฐ ๊ฐ’ "Coding For All"์— ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค. +4. *print()* ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํšŒ์‚ฌ ๋ณ€์ˆ˜๋ฅผ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค. +5. *len()* ๋ฉ”์„œ๋“œ์™€ *print()* ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํšŒ์‚ฌ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค. +6. *upper()* ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. +7. *lower()* ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์†Œ๋ฌธ์ž๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. +8. ๋ฌธ์ž์—ด *Coding For All* ์˜ ๊ฐ’์„ ํ˜•์‹ํ™”ํ•˜๋ ค๋ฉด capitalize(), title(), swapcase() ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์‹ญ์‹œ์˜ค. +9. *Coding For All* ๋ฌธ์ž์—ด์˜ ์ฒซ ๋ฒˆ์งธ ๋‹จ์–ด๋ฅผ ์ž˜๋ผ๋ƒ…๋‹ˆ๋‹ค. +10. Index, find ๋˜๋Š” ๊ธฐํƒ€ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ *Coding For All* ๋ฌธ์ž์—ด์— ๋‹จ์–ด Coding์ด ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. +11. ๋ฌธ์ž์—ด 'Coding For All'์˜ ์ฝ”๋”ฉ์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ Python์œผ๋กœ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค. +12. replace ๋ฉ”์„œ๋“œ ๋˜๋Š” ๊ธฐํƒ€ ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋‘๋ฅผ ์œ„ํ•œ Python์„ ๋ชจ๋‘๋ฅผ ์œ„ํ•œ Python์œผ๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. +13. ๊ณต๋ฐฑ์„ ๊ตฌ๋ถ„ ๊ธฐํ˜ธ๋กœ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ž์—ด 'Coding For All'์„ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค(split()). +14. "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon"์€ ์‰ผํ‘œ์—์„œ ๋ฌธ์ž์—ด์„ ๋‚˜๋ˆ•๋‹ˆ๋‹ค. +15. ๋ฌธ์ž์—ด *Coding For All* ์—์„œ ์ธ๋ฑ์Šค 0์— ์žˆ๋Š” ๋ฌธ์ž๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ? +16. ๋ฌธ์ž์—ด *Coding For All* ์—์„œ ์ธ๋ฑ์Šค 0์— ์žˆ๋Š” ๋ฌธ์ž๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ? +17. "Coding For All" ๋ฌธ์ž์—ด์—์„œ ์ธ๋ฑ์Šค 10์— ์žˆ๋Š” ๋ฌธ์ž๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ? +18. 'Python For Everyone'์ด๋ผ๋Š” ์ด๋ฆ„์˜ ์•ฝ์–ด ๋˜๋Š” ์•ฝ์–ด๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. +19. 'Coding For All'์ด๋ผ๋Š” ์ด๋ฆ„์˜ ์•ฝ์–ด ๋˜๋Š” ์•ฝ์–ด๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. +20. Index๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Coding For All์—์„œ C๊ฐ€ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค. +21. Index๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Coding For All์—์„œ F๊ฐ€ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค. +22. Coding For All People์—์„œ l์ด ๋งˆ์ง€๋ง‰์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ๊ฒฐ์ •ํ•˜๋ ค๋ฉด rfind๋ฅผ ์‚ฌ์šฉํ•˜์‹ญ์‹œ์˜ค. +23. ์ƒ‰์ธ ๋˜๋Š” ์ฐพ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ๋ฌธ์žฅ์—์„œ 'because'๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. +24. ์ƒ‰์ธ ๋˜๋Š” ์ฐพ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ๋ฌธ์žฅ์—์„œ 'because'๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. +25. ์ƒ‰์ธ ๋˜๋Š” ์ฐพ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ๋ฌธ์žฅ์—์„œ 'because'๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. +26. ์ƒ‰์ธ ๋˜๋Š” ์ฐพ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ๋ฌธ์žฅ์—์„œ 'because'๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์ฒ˜์Œ ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. +27. ๋‹ค์Œ ๋ฌธ์žฅ์—์„œ 'because because because'๋ผ๋Š” ๊ตฌ๋ฌธ์„ ์ž˜๋ผ๋ƒ…๋‹ˆ๋‹ค. +28. 'Coding For All'์€ ํ•˜์œ„ ๋ฌธ์ž์—ด *Coding* ์œผ๋กœ ์‹œ์ž‘ํ•ฉ๋‹ˆ๊นŒ? +29. 'Coding For All'์€ ํ•˜์œ„ ๋ฌธ์ž์—ด *์ฝ”๋”ฉ* ์œผ๋กœ ๋๋‚ฉ๋‹ˆ๊นŒ? +30. ' Coding For All ' , ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์—์„œ ์™ผ์ชฝ ๋ฐ ์˜ค๋ฅธ์ชฝ ํ›„ํ–‰ ๊ณต๋ฐฑ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. +31. ๋‹ค์Œ ๋ณ€์ˆ˜ ์ค‘ isidentifier() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ True๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ณ€์ˆ˜๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ? + - 30DaysOfPython + - thirty_days_of_python +32. ๋‹ค์Œ ๋ชฉ๋ก์—๋Š” ์ผ๋ถ€ ํŒŒ์ด์ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ์ด๋ฆ„์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค: ['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon']. ๊ณต๋ฐฑ ๋ฌธ์ž์—ด์ด ์žˆ๋Š” ํ•ด์‹œ๋กœ ๋ชฉ๋ก์— ๊ฐ€์ž…ํ•˜์‹ญ์‹œ์˜ค. +33. ์ƒˆ ์ค„ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ๋ฌธ์žฅ์„ ๊ตฌ๋ถ„ํ•ฉ๋‹ˆ๋‹ค. + ```py + I am enjoying this challenge. + I just wonder what is next. + ``` +34. ์ƒˆ ์ค„ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ๋ฌธ์žฅ์„ ๊ตฌ๋ถ„ํ•ฉ๋‹ˆ๋‹ค. + ```py + Name Age Country City + Asabeneh 250 Finland Helsinki + ``` +35. ๋ฌธ์ž์—ด ํ˜•์‹ ์ง€์ • ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค: + +```sh +radius = 10 +area = 3.14 * radius ** 2 +The area of a circle with radius 10 is 314 meters square. +``` + +1. ๋ฌธ์ž์—ด ํ˜•์‹ํ™” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค: + +```sh +8 + 6 = 14 +8 - 6 = 2 +8 * 6 = 48 +8 / 6 = 1.33 +8 % 6 = 2 +8 // 6 = 1 +8 ** 6 = 262144 +``` + +๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค! ๐ŸŽ‰ + +[<< Day 3](../03_Day_Operators/03_operators.md) | [Day 5 >>](../05_Day_Lists/05_lists.md) diff --git a/Korean/readme_ko.md b/Korean/readme_ko.md new file mode 100644 index 00000000..bc628609 --- /dev/null +++ b/Korean/readme_ko.md @@ -0,0 +1,454 @@ +# ๐Ÿ 30 Days Of Python + +|# Day | Topics | +|------|:---------------------------------------------------------:| +| 01 | [Introduction](./readme_ko.md)| +| 02 | [Variables, Built-in Functions](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)| +| 03 | [Operators](../03_Day_Operators/03_operators.md)| +| 04 | [Strings](../04_Day_Strings/04_strings.md)| +| 05 | [Lists](../05_Day_Lists/05_lists.md)| +| 06 | [Tuples](../06_Day_Tuples/06_tuples.md)| +| 07 | [Sets](../07_Day_Sets/07_sets.md)| +| 08 | [Dictionaries](../08_Day_Dictionaries/08_dictionaries.md)| +| 09 | [Conditionals](../09_Day_Conditionals/09_conditionals.md)| +| 10 | [Loops](../10_Day_Loops/10_loops.md)| +| 11 | [Functions](../11_Day_Functions/11_functions.md)| +| 12 | [Modules](../12_Day_Modules/12_modules.md)| +| 13 | [List Comprehension](../13_Day_List_comprehension/13_list_comprehension.md)| +| 14 | [Higher Order Functions](../14_Day_Higher_order_functions/14_higher_order_functions.md)| +| 15 | [Python Type Errors](../15_Day_Python_type_errors/15_python_type_errors.md)| +| 16 | [Python Date time](../16_Day_Python_date_time/16_python_datetime.md) | +| 17 | [Exception Handling](../17_Day_Exception_handling/17_exception_handling.md)| +| 18 | [Regular Expressions](../18_Day_Regular_expressions/18_regular_expressions.md)| +| 19 | [File Handling](../19_Day_File_handling/19_file_handling.md)| +| 20 | [Python Package Manager](../20_Day_Python_package_manager/20_python_package_manager.md)| +| 21 | [Classes and Objects](../21_Day_Classes_and_objects/21_classes_and_objects.md)| +| 22 | [Web Scraping](../22_Day_Web_scraping/22_web_scraping.md)| +| 23 | [Virtual Environment](../23_Day_Virtual_environment/23_virtual_environment.md)| +| 24 | [Statistics](../24_Day_Statistics/24_statistics.md)| +| 25 | [Pandas](../25_Day_Pandas/25_pandas.md)| +| 26 | [Python web](../26_Day_Python_web/26_python_web.md)| +| 27 | [Python with MongoDB](../27_Day_Python_with_mongodb/27_python_with_mongodb.md)| +| 28 | [API](../28_Day_API/28_API.md)| +| 29 | [Building API](../29_Day_Building_API/29_building_API.md)| +| 30 | [Conclusions](../30_Day_Conclusions/30_conclusions.md)| + +๐Ÿงก๐Ÿงก๐Ÿงก 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 >>](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) + +![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png) + +- [๐Ÿ 30 Days Of Python](#-30-days-of-python) +- [๐Ÿ“˜ Day 1](#-day-1) + - [ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค](#ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค) + - [์†Œ๊ฐœ](#์†Œ๊ฐœ) + - [์™œ Python์ด๋Š๋ƒ?](#์™œ-python์ด๋Š๋ƒ?) + - [ํ™˜๊ฒฝ ์„ค์ •](#ํ™˜๊ฒฝ-์„ค์ •) + - [Python ์„ค์น˜](#python-์„ค์น˜) + - [Python ์…ธ](#python-์…ธ) + - [Visual Studio Code ์„ค์น˜](#visual-studio-code-์„ค์น˜) + - [visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ](#visual-studio-code๋ฅผ-์‚ฌ์šฉํ•˜๊ธฐ) + - [Python ๊ธฐ๋ณธ](#python-๊ธฐ๋ณธ) + - [Python ๊ตฌ๋ฌธ](#python-๊ตฌ๋ฌธ) + - [Python ๋“ค์—ฌ์“ฐ๊ธฐ](#python-๋“ค์—ฌ์“ฐ๊ธฐ) + - [์ฃผ์„](#์ฃผ์„) + - [๋ฐ์ดํ„ฐ ํƒ€์ž…](#๋ฐ์ดํ„ฐ-ํƒ€์ž…) + - [Number](#number) + - [String](#string) + - [Booleans](#booleans) + - [List](#list) + - [Dictionary](#dictionary) + - [Tuple](#tuple) + - [Set](#set) + - [๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ](#๋ฐ์ดํ„ฐ-ํƒ€์ž…-์ฒดํฌ) + - [Python ํŒŒ์ผ](#python-ํŒŒ์ผ) + - [๐Ÿ’ป Exercises - Day 1](#-exercises---day-1) + - [Exercise: Level 1](#exercise-level-1) + - [Exercise: Level 2](#exercise-level-2) + - [Exercise: Level 3](#exercise-level-3) + +# ๐Ÿ“˜ Day 1 + +## ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค + +_30 days of Python_์— ์ฐธ์—ฌํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ•˜์‹  ๊ฒƒ์„ **์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค**. ์ด ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ๋˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ๋ชจ๋“  ๊ฒƒ๊ณผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ์ „์ฒด ๊ฐœ๋…์„ ๋ฐฐ์šฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๊ฐ€ ๋๋‚˜๋ฉด _30DaysOfPython_ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ์„œ๋ฅผ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. + +์ฑŒ๋ฆฐ์ง€์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด [30DaysOfPython challenge](https://t.me/ThirtyDaysOfPython) ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ๊ฐ€์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +## ์†Œ๊ฐœ + +Python์€ ๋ฒ”์šฉ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•œ ๊ณ ๊ธ‰ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์˜คํ”ˆ ์†Œ์Šค, ์ธํ„ฐํ”„๋ฆฌํ„ฐ, ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Python์€ ๋„ค๋œ๋ž€๋“œ ํ”„๋กœ๊ทธ๋ž˜๋จธ Guido van Rossum์ด ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์˜ ์ด๋ฆ„์€ ์˜๊ตญ ์Šค์ผ€์น˜ ์ฝ”๋ฏธ๋”” ์‹œ๋ฆฌ์ฆˆ *Month Python's Flying Circus* ์—์„œ ํŒŒ์ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ๋ฒ„์ „์€ 1991๋…„ 2์›” 20์ผ์— ์ถœ์‹œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ์ฑŒ๋ฆฐ์ง€๋Š” ์ตœ์‹  ๋ฒ„์ „์˜ Python์ธ Python 3๋ฅผ ์ฐจ๊ทผ์ฐจ๊ทผ ๋ฐฐ์šธ ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฃผ์ œ๋Š” 30์ผ๋กœ ๋‚˜๋‰˜๋ฉฐ, ๋งค์ผ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์„ค๋ช…, ์‹ค์ œ ์‚ฌ๋ก€, ๋งŽ์€ ์‹ค์Šต ๋ฐ ํ”„๋กœ์ ํŠธ๊ฐ€ ํฌํ•จ๋œ ์—ฌ๋Ÿฌ ์ฃผ์ œ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. + +์ด ์ฑŒ๋ฆฐ์ง€๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ๋ฐฐ์šฐ๊ณ ์ž ํ•˜๋Š” ์ดˆ๋ณด์ž์™€ ์ „๋ฌธ๊ฐ€๋ฅผ ์œ„ํ•ด ๊ณ ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•˜๋Š” ๋ฐ 30~100์ผ์ด ์†Œ์š”๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์ด ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•  ํ™•๋ฅ ์ด ๋†’์Šต๋‹ˆ๋‹ค. +์‹œ๊ฐ์  ํ•™์Šต์ž์ด๊ฑฐ๋‚˜ ๋™์˜์ƒ์„ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ ์ด [์™„์ „ ์ดˆ๋ณด๋ฅผ ์œ„ํ•œ Python ๋™์˜์ƒ](https://www.youtube.com/watch?v=11OYpBrhdyM)์œผ๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +## ์™œ Python์ด๋Š๋ƒ? + +์ธ๊ฐ„์˜ ์–ธ์–ด์— ๋งค์šฐ ๊ฐ€๊น๊ณ  ๋ฐฐ์šฐ๊ธฐ ์‰ฝ๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฌ์šด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. +Python์€ ๋‹ค์–‘ํ•œ ์‚ฐ์—… ๋ฐ ํšŒ์‚ฌ(Google ํฌํ•จ)์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์›น ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ๋ฐ์Šคํฌํ†ฑ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ์‹œ์Šคํ…œ ๊ด€๋ฆฌ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Python์€ ๋ฐ์ดํ„ฐ ๊ณผํ•™ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ์ปค๋ฎค๋‹ˆํ‹ฐ์—์„œ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด Python ํ•™์Šต์„ ์‹œ์ž‘ํ•˜๋„๋ก ์„ค๋“ํ•˜๊ธฐ์— ์ถฉ๋ถ„ํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. Python์€ ์„ธ์ƒ์„ ์ง€๋ฐฐํ•˜๊ณ  ์žˆ์œผ๋‹ˆ ์ง€๋ฐฐ ๋‹นํ•˜๊ธฐ ์ „์— Python์„ ์ง€๋ฐฐํ•˜์‹ญ์‹œ์˜ค. +## ํ™˜๊ฒฝ ์„ค์ • + +### Python ์„ค์น˜ + +Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด Python์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python์„ [๋‹ค์šด๋กœ๋“œ](https://www.python.org/)ํ•ฉ์‹œ๋‹ค. +Windows ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. + + + +macOS ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. + +[![Windows์—์„œ ์„ค์น˜](../images/installing_on_windows.png)](https://www.python.org/) + +Python์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ์žฅ์น˜ ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค. + +```shell +python --version +``` + +![Python Version](../images/python_versio.png) + +ํ„ฐ๋ฏธ๋„์—์„œ ๋ณด์‹œ๋‹ค์‹œํ”ผ ์ €๋Š” ํ˜„์žฌ _Python 3.7.5_ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ Python ๋ฒ„์ „์€ ๋‚ด ๋ฒ„์ „๊ณผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์ง€๋งŒ 3.6 ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python ๋ฒ„์ „์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ž˜ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์ปดํ“จํ„ฐ์— Python์ด ์„ค์น˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์„น์…˜์œผ๋กœ ๊ณ„์† ์ง„ํ–‰ํ•˜์‹ญ์‹œ์˜ค. + +### Python ์…ธ + +Python์€ ํ•ด์„๋œ ์Šคํฌ๋ฆฝํŒ… ์–ธ์–ด์ด๋ฏ€๋กœ ์ปดํŒŒ์ผํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ํ•œ ์ค„์”ฉ ์‹คํ–‰ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. Python์€ _Python Shell(Python Interactive Shell)_๊ณผ ํ•จ๊ป˜ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ๋‹จ์ผ Python ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. + +Python Shell์€ ์‚ฌ์šฉ์ž์˜ Python ์ฝ”๋“œ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•˜์—ฌ ๋‹ค์Œ ์ค„์— ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. +ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ(cmd)๋ฅผ ์—ด๊ณ  ์“ฐ๊ธฐ: + +```shell +python +``` + +![Python Scripting Shell](../images/opening_python_shell.png) + +Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฌ๊ณ  Python ์ฝ”๋“œ(Python ์Šคํฌ๋ฆฝํŠธ)๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ๊ธฐํ˜ธ >>> ์˜†์— Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  Enter๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. +Python ์Šคํฌ๋ฆฝํŒ… ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + +![Python script on Python shell](../images/adding_on_python_shell.png) + +ํ›Œ๋ฅญํ•ฉ๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์–ด๋–ป๊ฒŒ ๋‹ซ์Šต๋‹ˆ๊นŒ? +์…ธ์„ ๋‹ซ์œผ๋ ค๋ฉด ๊ธฐํ˜ธ ์˜†์— >> **exit()** ๋ช…๋ น์„ ์ž‘์„ฑํ•˜๊ณ  Enter ํ‚ค๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. + +![Exit from python shell](../images/exit_from_shell.png) + +์ด์ œ Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ฌ๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•˜์Šต๋‹ˆ๋‹ค. + +Python์€ Python์ด ์ดํ•ดํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ณ ์˜์ ์ธ ์‹ค์ˆ˜๋ฅผ ํ•˜๊ณ  Python์ด ๋ฌด์—‡์„ ๋ฐ˜ํ™˜ํ•˜๋Š”์ง€ ๋ด…์‹œ๋‹ค. + +![Invalid Syntax Error](../images/invalid_syntax_error.png) + +๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด Python์€ ์šฐ๋ฆฌ๊ฐ€ ์ €์ง€๋ฅธ ์‹ค์ˆ˜์™€ _Syntax Error: invalid syntax_๋ฅผ ์•Œ๊ณ  ์žˆ์„ ์ •๋„๋กœ ์˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. Python์—์„œ x๋ฅผ ๊ณฑ์…ˆ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ (x)๊ฐ€ Python์—์„œ ์œ ํšจํ•œ ๊ตฌ๋ฌธ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. (**x**) ๋Œ€์‹  ๊ณฑ์…ˆ์— ๋ณ„ํ‘œ(*)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜๋Š” ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. + +ํ”„๋กœ๊ทธ๋žจ์—์„œ ์˜ค๋ฅ˜๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์ œ๊ฑฐํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ *๋””๋ฒ„๊น…*์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. **x** ๋Œ€์‹  *๋ฅผ ๋„ฃ์–ด ๋””๋ฒ„๊น…ํ•ด ๋ด…์‹œ๋‹ค. + +![Fixing Syntax Error](../images/fixing_syntax_error.png) + +๋ฒ„๊ทธ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ๊ณ  ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋˜์—ˆ์œผ๋ฉฐ ์˜ˆ์ƒํ–ˆ๋˜ ๊ฒฐ๊ณผ๋ฅผ ์–ป์—ˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ๋กœ์„œ ๋งค์ผ ์ด๋Ÿฌํ•œ ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๋ฅผ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•์„ ์•„๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋””๋ฒ„๊น…์„ ์ž˜ํ•˜๋ ค๋ฉด ์–ด๋–ค ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์ดํ•ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” Python ์˜ค๋ฅ˜ ์ค‘ ์ผ๋ถ€๋Š” *SyntaxError*, *IndexError*, *NameError*, *ModuleNotFoundError*, *KeyError*, *ImportError*, *AttributeError*, *TypeError*, *ValueError*, *ZeroDivisionError* ๋“ฑ์ž…๋‹ˆ๋‹ค. ์ดํ›„ ์„น์…˜์—์„œ ๋‹ค๋ฅธ Python **_์˜ค๋ฅ˜ ์œ ํ˜•_**์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค. + +Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋” ์—ฐ์Šตํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋™ํ•˜์—ฌ **python**์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์”๋‹ˆ๋‹ค. + +![Python Scripting Shell](../images/opening_python_shell.png) + +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์—์„œ ์ฃผ์„์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค + +```shell + # ์ฃผ์„์€ ํ•ด์‹œ๋กœ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. + # (#) ์‹ฌ๋ณผ๋กœ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์€ ํŒŒ์ด์ฌ ์ฃผ์„์ž…๋‹ˆ๋‹ค. +``` + +![Maths on python shell](../images/maths_on_python_shell.png) + +๋‹ค์Œ ์„น์…˜์œผ๋กœ ์ด๋™ํ•˜๊ธฐ ์ „์— Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ๋” ๋งŽ์€ ์—ฐ์Šต์„ ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์…ธ์—์„œ _exit()_๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์—ด๋ฆฐ ์…ธ์„ ๋‹ซ์•˜๋‹ค๊ฐ€ ๋‹ค์‹œ ์—ด์–ด Python ์…ธ์—์„œ ํ…์ŠคํŠธ๋ฅผ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์„ ์—ฐ์Šตํ•ด ๋ด…์‹œ๋‹ค. + +![Writing String on python shell](../images/writing_string_on_shell.png) + +### Visual Studio Code ์„ค์น˜ + +Python ๋Œ€ํ™”ํ˜• ์…ธ์€ ์ž‘์€ ์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์‹œ๋„ํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•˜๋Š” ๋ฐ ์ ํ•ฉํ•˜์ง€๋งŒ ํฐ ํ”„๋กœ์ ํŠธ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์ž‘์—… ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ์ž๋Š” ๋‹ค์–‘ํ•œ ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Visual Studio Code๋Š” ๋งค์šฐ ์ธ๊ธฐ ์žˆ๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ…์ŠคํŠธ ํŽธ์ง‘๊ธฐ์ž…๋‹ˆ๋‹ค. ๋‚˜๋Š” vscode์˜ ํŒฌ์ด๊ณ  Visual Studio ์ฝ”๋“œ๋ฅผ [๋‹ค์šด๋กœ๋“œ](https://code.visualstudio.com/)ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•˜๊ณ  ์‹ถ์ง€๋งŒ, ๋‹ค๋ฅธ ํŽธ์ง‘์ž๋ฅผ ์„ ํ˜ธํ•œ๋‹ค๋ฉด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์ž์œ ๋กญ๊ฒŒ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค. + +[![Visual Studio Code](../images/vscode.png)](https://code.visualstudio.com/) + +Visual Studio Code๋ฅผ ์„ค์น˜ํ•˜์…จ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. +๋น„๋””์˜ค๋ฅผ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ Python์šฉ Visual Studio Code[๋น„๋””์˜ค ์ž์Šต์„œ](https://www.youtube.com/watch?v=bn7Cx4z-vSo)๋ฅผ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +#### visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ + +Visual Studio ์•„์ด์ฝ˜์„ ๋‘ ๋ฒˆ ํด๋ฆญํ•˜์—ฌ Visual Studio ์ฝ”๋“œ๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ์—ด๋ฉด ์ด๋Ÿฐ ์ข…๋ฅ˜์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋ ˆ์ด๋ธ”์ด ์ง€์ •๋œ ์•„์ด์ฝ˜์„ ๋”ฐ๋ผํ•ด๋ณด์„ธ์š”. + +![Visual studio Code](../images/vscode_ui.png) + +๋ฐ”ํƒ• ํ™”๋ฉด์— 30DaysOfPython์ด๋ผ๋Š” ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฝ์‹œ๋‹ค. + +![Opening Project on Visual studio](../images/how_to_open_project_on_vscode.png) + +![Opening a project](../images/opening_project.png) + +ํŒŒ์ผ์„ ์—ด๋ฉด 30DaysOfPython ํ”„๋กœ์ ํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์— ํŒŒ์ผ๊ณผ ํด๋”๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด ์ฒซ ๋ฒˆ์งธ ํŒŒ์ผ์ธ helloworld.py๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ๋„ ๋˜‘๊ฐ™์ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +![Creating a python file](../images/helloworld.png) + +ํ•˜๋ฃจ๋™์•ˆ ์˜ค๋ž˜ ์ฝ”๋”ฉ์„ ํ•œ ํ›„์— ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ๋‹ซ๊ณ  ์‹ถ์Šต๋‹ˆ๊นŒ? ์ด๋ ‡๊ฒŒ ์—ด๋ฆฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ซ์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. + +![Closing project](../images/closing_opened_project.png) + +์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ •์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์„ ์‹œ์ž‘ํ•ด ๋ด…์‹œ๋‹ค. + +## Python ๊ธฐ๋ณธ + +### Python ๊ตฌ๋ฌธ + +Python ์Šคํฌ๋ฆฝํŠธ๋Š” Python ๋Œ€ํ™”ํ˜• ์…ธ ๋˜๋Š” ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ์—์„œ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Python ํŒŒ์ผ์˜ ํ™•์žฅ์ž๋Š” .py์ž…๋‹ˆ๋‹ค. + +### Python ๋“ค์—ฌ ์“ฐ๊ธฐ + +๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ํ…์ŠคํŠธ์˜ ๊ณต๋ฐฑ์ž…๋‹ˆ๋‹ค. ๋งŽ์€ ์–ธ์–ด์—์„œ ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ Python์€ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ๋Š” ์ค‘๊ด„ํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋“ค์—ฌ์“ฐ๊ธฐ ๋Œ€์‹  ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. Python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ๋ฒ„๊ทธ ์ค‘ ํ•˜๋‚˜๋Š” ์ž˜๋ชป๋œ ๋“ค์—ฌ์“ฐ๊ธฐ์ž…๋‹ˆ๋‹ค. + +![Indentation Error](../images/indentation.png) + +### ์ฃผ์„ + +์ฃผ์„์€ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ค๊ณ  ์ฝ”๋“œ์— ์„ค๋ช…์„ ๋‚จ๊ธฐ๊ธฐ ์œ„ํ•ด ๋งค์šฐ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. Python์€ ์ฝ”๋“œ์˜ ์ฃผ์„ ๋ถ€๋ถ„์„ ์‹คํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. +Python์—์„œ ํ•ด์‹œ(#)๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ชจ๋“  ํ…์ŠคํŠธ๋Š” ์ฃผ์„์ž…๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:ํ•œ ๋ฌธ์žฅ ์ฃผ์„** + +```shell + # 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 + +```shell +"""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 + +์ž‘์€๋”ฐ์˜ดํ‘œ ๋˜๋Š” ํฐ๋”ฐ์˜ดํ‘œ ์•„๋ž˜์— ์žˆ๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ๋ฌธ์ž ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์ด ๋‘ ๋ฌธ์žฅ ์ด์ƒ์ธ ๊ฒฝ์šฐ ์‚ผ์ค‘ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:** + +```py +'Asabeneh' +'Finland' +'Python' +'I love teaching' +'I hope you are enjoying the first day of 30DaysOfPython Challenge' +``` + +#### Boolean + +๋ถ€์šธ ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ True ๋˜๋Š” False ๊ฐ’์ž…๋‹ˆ๋‹ค. T์™€ F๋Š” ํ•ญ์ƒ ๋Œ€๋ฌธ์ž์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:** + +```python + True # ๋ถˆ์ด ์ผœ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ์ฐธ์ž…๋‹ˆ๋‹ค. + False # ๋ถˆ์ด ๊บผ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ๊ฑฐ์ง“์ž…๋‹ˆ๋‹ค. +``` + +#### List + +Python ๋ฆฌ์ŠคํŠธ๋Š” ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ ์œ ํ˜• ํ•ญ๋ชฉ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ ฌ๋œ ์ปฌ๋ ‰์…˜์ž…๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ๋Š” JavaScript์˜ ๋ฐฐ์—ด๊ณผ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค. + +**Example:** + +```py +[0, 1, 2, 3, 4, 5] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ์ˆซ์ž ๋ฆฌ์ŠคํŠธ +['Banana', 'Orange', 'Mango', 'Avocado'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ณผ์ผ) +['Finland','Estonia', 'Sweden','Norway'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ตญ๊ฐ€) +['Banana', 10, False, 9.81] # ๋ฆฌ์ŠคํŠธ์˜ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด, ์ •์ˆ˜, ๋ถ€์šธ ๋ฐ ๋ถ€๋™ ์†Œ์ˆ˜์  +``` + +#### Dictionary + +Python ์‚ฌ์ „ ๊ฐœ์ฒด๋Š” ํ‚ค ๊ฐ’ ์Œ ํ˜•์‹์˜ ์ •๋ ฌ๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. + +**Example:** + +```py +{ +'first_name':'Asabeneh', +'last_name':'Yetayeh', +'country':'Finland', +'age':250, +'is_married':True, +'skills':['JS', 'React', 'Node', 'Python'] +} +``` + +#### Tuple + +ํŠœํ”Œ์€ ๋ชฉ๋ก๊ณผ ๊ฐ™์€ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ์ •๋ ฌ๋œ ๋ชจ์Œ์ด์ง€๋งŒ ํŠœํ”Œ์ด ์ƒ์„ฑ๋˜๋ฉด ์ˆ˜์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ๋“ค์€ ๋ณ€ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. + +**Example:** + +```py +('Asabeneh', 'Pawel', 'Brook', 'Abraham', 'Lidiya') # Names +``` + +```py +('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets +``` + +#### Set + +์ง‘ํ•ฉ์€ ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ์œ ์‚ฌํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ๋‹ฌ๋ฆฌ ์ง‘ํ•ฉ์€ ์ˆœ์„œ๊ฐ€ ์ง€์ •๋œ ํ•ญ๋ชฉ ๋ชจ์Œ์ด ์•„๋‹™๋‹ˆ๋‹ค. ์ˆ˜ํ•™์—์„œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ Python์—์„œ set์€ ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ๋งŒ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. + +์ดํ›„ ์„น์…˜์—์„œ๋Š” ๊ฐ๊ฐ์˜ ๋ชจ๋“  Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. + +**Example:** + +```py +{2, 4, 3, 5} +{3.14, 9.81, 2.7} # order is not important in set +``` + +### ๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ + +ํŠน์ • ๋ฐ์ดํ„ฐ/๋ณ€์ˆ˜์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด **type** ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์–‘ํ•œ Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: + +![Checking Data types](../images/checking_data_types.png) + +### Python ํŒŒ์ผ + +๋จผ์ € ํ”„๋กœ์ ํŠธ ํด๋”์ธ 30DaysOfPython์„ ์—ฝ๋‹ˆ๋‹ค. ์ด ํด๋”๊ฐ€ ์—†์œผ๋ฉด 30DaysOfPython์ด๋ผ๋Š” ํด๋” ์ด๋ฆ„์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด ํด๋” ์•ˆ์— helloworld.py๋ผ๋Š” ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด์ œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ˆ˜ํ–‰ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. + +Python ๋Œ€ํ™”ํ˜• ์…ธ์€ **print**๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ธ์‡„ํ–ˆ์ง€๋งŒ Visual Studio ์ฝ”๋“œ์—์„œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ ค๋ฉด ๋‚ด์žฅ ํ•จ์ˆ˜ *print()๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. *print()* ๋‚ด์žฅ ํ•จ์ˆ˜๋Š” *print('arument1', 'argument2', 'argument3')*์™€ ๊ฐ™์ด ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. + +**Example:** + +ํŒŒ์ผ ์ด๋ฆ„์€ helloworld.py. + +```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](../images/running_python_script.png) + +๐ŸŒ• ์ข‹์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 1์ผ์ฐจ ๋„์ „์„ ์™„๋ฃŒํ–ˆ๊ณ  ๋‹น์‹ ์€ ์œ„๋Œ€ํ•œ ์—ฌ์ •์— ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•ด๋ด…์‹œ๋‹ค. + +## ๐Ÿ’ป Exercises - Day 1 + +### Exercise: Level 1 + +1. ์‚ฌ์šฉ ์ค‘์ธ Python ๋ฒ„์ „ ํ™•์ธ +2. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ด๊ณ  ๋‹ค์Œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ํ”ผ์—ฐ์‚ฐ์ž๋Š” 3๊ณผ 4์ž…๋‹ˆ๋‹ค. + - ๋”ํ•˜๊ธฐ(+) + - ๋นผ๊ธฐ(-) + - ๊ณฑํ•˜๊ธฐ(\*) + - ๋‚˜๋จธ์ง€(%) + - ๋‚˜๋ˆ„๊ธฐ(/) + - ์ง€์ˆ˜(\*\*) + - ์ •์ˆ˜ ๋‚˜๋ˆ„๊ธฐ(//) +3. Python ๋Œ€ํ™”ํ˜• ์…ธ์— ๋ฌธ์ž์—ด์„ ์”๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: + - ์ด๋ฆ„ + - ๊ฐ€์กฑ ์ด๋ฆ„ + - ๊ตญ๊ฐ€ ์ด๋ฆ„ + - I am enjoying 30 days of python +4. ๋‹ค์Œ ๋ฐ์ดํ„ฐ์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.: + - 10 + - 9.8 + - 3.14 + - 4 - 4j + - ['Asabeneh', 'Python', 'Finland'] + - ์ด๋ฆ„ + - ๊ฐ€์กฑ ์ด๋ฆ„ + - ๊ตญ๊ฐ€ ์ด๋ฆ„ + +### 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](https://en.wikipedia.org/wiki/Euclidean_distance#:~:text=In%20mathematics%2C%20the%20Euclidean%20distance,being%20called%20the%20Pythagorean%20distance.) (2, 3) ๊ณผ (10, 8) ์‚ฌ์ด + +๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค ! ๐ŸŽ‰ + +[Day 2 >>](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) \ No newline at end of file From 088e613ddeb4ce7e7e32685393a0033f702e4aab Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Fri, 9 Dec 2022 10:34:56 +0900 Subject: [PATCH 5/8] rm lang-ko --- lang-ko/readme_ko.md | 454 ------------------------------------------- 1 file changed, 454 deletions(-) delete mode 100644 lang-ko/readme_ko.md diff --git a/lang-ko/readme_ko.md b/lang-ko/readme_ko.md deleted file mode 100644 index bc628609..00000000 --- a/lang-ko/readme_ko.md +++ /dev/null @@ -1,454 +0,0 @@ -# ๐Ÿ 30 Days Of Python - -|# Day | Topics | -|------|:---------------------------------------------------------:| -| 01 | [Introduction](./readme_ko.md)| -| 02 | [Variables, Built-in Functions](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)| -| 03 | [Operators](../03_Day_Operators/03_operators.md)| -| 04 | [Strings](../04_Day_Strings/04_strings.md)| -| 05 | [Lists](../05_Day_Lists/05_lists.md)| -| 06 | [Tuples](../06_Day_Tuples/06_tuples.md)| -| 07 | [Sets](../07_Day_Sets/07_sets.md)| -| 08 | [Dictionaries](../08_Day_Dictionaries/08_dictionaries.md)| -| 09 | [Conditionals](../09_Day_Conditionals/09_conditionals.md)| -| 10 | [Loops](../10_Day_Loops/10_loops.md)| -| 11 | [Functions](../11_Day_Functions/11_functions.md)| -| 12 | [Modules](../12_Day_Modules/12_modules.md)| -| 13 | [List Comprehension](../13_Day_List_comprehension/13_list_comprehension.md)| -| 14 | [Higher Order Functions](../14_Day_Higher_order_functions/14_higher_order_functions.md)| -| 15 | [Python Type Errors](../15_Day_Python_type_errors/15_python_type_errors.md)| -| 16 | [Python Date time](../16_Day_Python_date_time/16_python_datetime.md) | -| 17 | [Exception Handling](../17_Day_Exception_handling/17_exception_handling.md)| -| 18 | [Regular Expressions](../18_Day_Regular_expressions/18_regular_expressions.md)| -| 19 | [File Handling](../19_Day_File_handling/19_file_handling.md)| -| 20 | [Python Package Manager](../20_Day_Python_package_manager/20_python_package_manager.md)| -| 21 | [Classes and Objects](../21_Day_Classes_and_objects/21_classes_and_objects.md)| -| 22 | [Web Scraping](../22_Day_Web_scraping/22_web_scraping.md)| -| 23 | [Virtual Environment](../23_Day_Virtual_environment/23_virtual_environment.md)| -| 24 | [Statistics](../24_Day_Statistics/24_statistics.md)| -| 25 | [Pandas](../25_Day_Pandas/25_pandas.md)| -| 26 | [Python web](../26_Day_Python_web/26_python_web.md)| -| 27 | [Python with MongoDB](../27_Day_Python_with_mongodb/27_python_with_mongodb.md)| -| 28 | [API](../28_Day_API/28_API.md)| -| 29 | [Building API](../29_Day_Building_API/29_building_API.md)| -| 30 | [Conclusions](../30_Day_Conclusions/30_conclusions.md)| - -๐Ÿงก๐Ÿงก๐Ÿงก 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 >>](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) - -![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png) - -- [๐Ÿ 30 Days Of Python](#-30-days-of-python) -- [๐Ÿ“˜ Day 1](#-day-1) - - [ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค](#ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค) - - [์†Œ๊ฐœ](#์†Œ๊ฐœ) - - [์™œ Python์ด๋Š๋ƒ?](#์™œ-python์ด๋Š๋ƒ?) - - [ํ™˜๊ฒฝ ์„ค์ •](#ํ™˜๊ฒฝ-์„ค์ •) - - [Python ์„ค์น˜](#python-์„ค์น˜) - - [Python ์…ธ](#python-์…ธ) - - [Visual Studio Code ์„ค์น˜](#visual-studio-code-์„ค์น˜) - - [visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ](#visual-studio-code๋ฅผ-์‚ฌ์šฉํ•˜๊ธฐ) - - [Python ๊ธฐ๋ณธ](#python-๊ธฐ๋ณธ) - - [Python ๊ตฌ๋ฌธ](#python-๊ตฌ๋ฌธ) - - [Python ๋“ค์—ฌ์“ฐ๊ธฐ](#python-๋“ค์—ฌ์“ฐ๊ธฐ) - - [์ฃผ์„](#์ฃผ์„) - - [๋ฐ์ดํ„ฐ ํƒ€์ž…](#๋ฐ์ดํ„ฐ-ํƒ€์ž…) - - [Number](#number) - - [String](#string) - - [Booleans](#booleans) - - [List](#list) - - [Dictionary](#dictionary) - - [Tuple](#tuple) - - [Set](#set) - - [๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ](#๋ฐ์ดํ„ฐ-ํƒ€์ž…-์ฒดํฌ) - - [Python ํŒŒ์ผ](#python-ํŒŒ์ผ) - - [๐Ÿ’ป Exercises - Day 1](#-exercises---day-1) - - [Exercise: Level 1](#exercise-level-1) - - [Exercise: Level 2](#exercise-level-2) - - [Exercise: Level 3](#exercise-level-3) - -# ๐Ÿ“˜ Day 1 - -## ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค - -_30 days of Python_์— ์ฐธ์—ฌํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ•˜์‹  ๊ฒƒ์„ **์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค**. ์ด ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ๋˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ๋ชจ๋“  ๊ฒƒ๊ณผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ์ „์ฒด ๊ฐœ๋…์„ ๋ฐฐ์šฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๊ฐ€ ๋๋‚˜๋ฉด _30DaysOfPython_ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ์„œ๋ฅผ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. - -์ฑŒ๋ฆฐ์ง€์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด [30DaysOfPython challenge](https://t.me/ThirtyDaysOfPython) ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ๊ฐ€์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - -## ์†Œ๊ฐœ - -Python์€ ๋ฒ”์šฉ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•œ ๊ณ ๊ธ‰ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์˜คํ”ˆ ์†Œ์Šค, ์ธํ„ฐํ”„๋ฆฌํ„ฐ, ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Python์€ ๋„ค๋œ๋ž€๋“œ ํ”„๋กœ๊ทธ๋ž˜๋จธ Guido van Rossum์ด ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์˜ ์ด๋ฆ„์€ ์˜๊ตญ ์Šค์ผ€์น˜ ์ฝ”๋ฏธ๋”” ์‹œ๋ฆฌ์ฆˆ *Month Python's Flying Circus* ์—์„œ ํŒŒ์ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ๋ฒ„์ „์€ 1991๋…„ 2์›” 20์ผ์— ์ถœ์‹œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ์ฑŒ๋ฆฐ์ง€๋Š” ์ตœ์‹  ๋ฒ„์ „์˜ Python์ธ Python 3๋ฅผ ์ฐจ๊ทผ์ฐจ๊ทผ ๋ฐฐ์šธ ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฃผ์ œ๋Š” 30์ผ๋กœ ๋‚˜๋‰˜๋ฉฐ, ๋งค์ผ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์„ค๋ช…, ์‹ค์ œ ์‚ฌ๋ก€, ๋งŽ์€ ์‹ค์Šต ๋ฐ ํ”„๋กœ์ ํŠธ๊ฐ€ ํฌํ•จ๋œ ์—ฌ๋Ÿฌ ์ฃผ์ œ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. - -์ด ์ฑŒ๋ฆฐ์ง€๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ๋ฐฐ์šฐ๊ณ ์ž ํ•˜๋Š” ์ดˆ๋ณด์ž์™€ ์ „๋ฌธ๊ฐ€๋ฅผ ์œ„ํ•ด ๊ณ ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•˜๋Š” ๋ฐ 30~100์ผ์ด ์†Œ์š”๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน์— ์ ๊ทน์ ์œผ๋กœ ์ฐธ์—ฌํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์ด ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ•  ํ™•๋ฅ ์ด ๋†’์Šต๋‹ˆ๋‹ค. -์‹œ๊ฐ์  ํ•™์Šต์ž์ด๊ฑฐ๋‚˜ ๋™์˜์ƒ์„ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ ์ด [์™„์ „ ์ดˆ๋ณด๋ฅผ ์œ„ํ•œ Python ๋™์˜์ƒ](https://www.youtube.com/watch?v=11OYpBrhdyM)์œผ๋กœ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - -## ์™œ Python์ด๋Š๋ƒ? - -์ธ๊ฐ„์˜ ์–ธ์–ด์— ๋งค์šฐ ๊ฐ€๊น๊ณ  ๋ฐฐ์šฐ๊ธฐ ์‰ฝ๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฌ์šด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. -Python์€ ๋‹ค์–‘ํ•œ ์‚ฐ์—… ๋ฐ ํšŒ์‚ฌ(Google ํฌํ•จ)์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์›น ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ๋ฐ์Šคํฌํ†ฑ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ, ์‹œ์Šคํ…œ ๊ด€๋ฆฌ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Python์€ ๋ฐ์ดํ„ฐ ๊ณผํ•™ ๋ฐ ๊ธฐ๊ณ„ ํ•™์Šต ์ปค๋ฎค๋‹ˆํ‹ฐ์—์„œ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด Python ํ•™์Šต์„ ์‹œ์ž‘ํ•˜๋„๋ก ์„ค๋“ํ•˜๊ธฐ์— ์ถฉ๋ถ„ํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. Python์€ ์„ธ์ƒ์„ ์ง€๋ฐฐํ•˜๊ณ  ์žˆ์œผ๋‹ˆ ์ง€๋ฐฐ ๋‹นํ•˜๊ธฐ ์ „์— Python์„ ์ง€๋ฐฐํ•˜์‹ญ์‹œ์˜ค. -## ํ™˜๊ฒฝ ์„ค์ • - -### Python ์„ค์น˜ - -Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด Python์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python์„ [๋‹ค์šด๋กœ๋“œ](https://www.python.org/)ํ•ฉ์‹œ๋‹ค. -Windows ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. - - - -macOS ์‚ฌ์šฉ์ž์ธ ๊ฒฝ์šฐ. ๋นจ๊ฐ„์ƒ‰ ๋™๊ทธ๋ผ๋ฏธ ์นœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. - -[![Windows์—์„œ ์„ค์น˜](../images/installing_on_windows.png)](https://www.python.org/) - -Python์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ์žฅ์น˜ ํ„ฐ๋ฏธ๋„์— ๋‹ค์Œ ๋ช…๋ น์„ ์ž‘์„ฑํ•˜์‹ญ์‹œ์˜ค. - -```shell -python --version -``` - -![Python Version](../images/python_versio.png) - -ํ„ฐ๋ฏธ๋„์—์„œ ๋ณด์‹œ๋‹ค์‹œํ”ผ ์ €๋Š” ํ˜„์žฌ _Python 3.7.5_ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ Python ๋ฒ„์ „์€ ๋‚ด ๋ฒ„์ „๊ณผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์ง€๋งŒ 3.6 ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Python ๋ฒ„์ „์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ž˜ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์ปดํ“จํ„ฐ์— Python์ด ์„ค์น˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์„น์…˜์œผ๋กœ ๊ณ„์† ์ง„ํ–‰ํ•˜์‹ญ์‹œ์˜ค. - -### Python ์…ธ - -Python์€ ํ•ด์„๋œ ์Šคํฌ๋ฆฝํŒ… ์–ธ์–ด์ด๋ฏ€๋กœ ์ปดํŒŒ์ผํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ํ•œ ์ค„์”ฉ ์‹คํ–‰ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. Python์€ _Python Shell(Python Interactive Shell)_๊ณผ ํ•จ๊ป˜ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ๋‹จ์ผ Python ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. - -Python Shell์€ ์‚ฌ์šฉ์ž์˜ Python ์ฝ”๋“œ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•˜์—ฌ ๋‹ค์Œ ์ค„์— ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. -ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ(cmd)๋ฅผ ์—ด๊ณ  ์“ฐ๊ธฐ: - -```shell -python -``` - -![Python Scripting Shell](../images/opening_python_shell.png) - -Python ๋Œ€ํ™”ํ˜• ์…ธ์ด ์—ด๋ฆฌ๊ณ  Python ์ฝ”๋“œ(Python ์Šคํฌ๋ฆฝํŠธ)๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. ๊ธฐํ˜ธ >>> ์˜†์— Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  Enter๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. -Python ์Šคํฌ๋ฆฝํŒ… ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. - -![Python script on Python shell](../images/adding_on_python_shell.png) - -ํ›Œ๋ฅญํ•ฉ๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ฒซ ๋ฒˆ์งธ Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์–ด๋–ป๊ฒŒ ๋‹ซ์Šต๋‹ˆ๊นŒ? -์…ธ์„ ๋‹ซ์œผ๋ ค๋ฉด ๊ธฐํ˜ธ ์˜†์— >> **exit()** ๋ช…๋ น์„ ์ž‘์„ฑํ•˜๊ณ  Enter ํ‚ค๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. - -![Exit from python shell](../images/exit_from_shell.png) - -์ด์ œ Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ฌ๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•˜์Šต๋‹ˆ๋‹ค. - -Python์€ Python์ด ์ดํ•ดํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ณ ์˜์ ์ธ ์‹ค์ˆ˜๋ฅผ ํ•˜๊ณ  Python์ด ๋ฌด์—‡์„ ๋ฐ˜ํ™˜ํ•˜๋Š”์ง€ ๋ด…์‹œ๋‹ค. - -![Invalid Syntax Error](../images/invalid_syntax_error.png) - -๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด Python์€ ์šฐ๋ฆฌ๊ฐ€ ์ €์ง€๋ฅธ ์‹ค์ˆ˜์™€ _Syntax Error: invalid syntax_๋ฅผ ์•Œ๊ณ  ์žˆ์„ ์ •๋„๋กœ ์˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. Python์—์„œ x๋ฅผ ๊ณฑ์…ˆ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ (x)๊ฐ€ Python์—์„œ ์œ ํšจํ•œ ๊ตฌ๋ฌธ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ตฌ๋ฌธ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. (**x**) ๋Œ€์‹  ๊ณฑ์…ˆ์— ๋ณ„ํ‘œ(*)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜ํ™˜๋œ ์˜ค๋ฅ˜๋Š” ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. - -ํ”„๋กœ๊ทธ๋žจ์—์„œ ์˜ค๋ฅ˜๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ์ œ๊ฑฐํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ *๋””๋ฒ„๊น…*์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. **x** ๋Œ€์‹  *๋ฅผ ๋„ฃ์–ด ๋””๋ฒ„๊น…ํ•ด ๋ด…์‹œ๋‹ค. - -![Fixing Syntax Error](../images/fixing_syntax_error.png) - -๋ฒ„๊ทธ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ๊ณ  ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋˜์—ˆ์œผ๋ฉฐ ์˜ˆ์ƒํ–ˆ๋˜ ๊ฒฐ๊ณผ๋ฅผ ์–ป์—ˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ๋กœ์„œ ๋งค์ผ ์ด๋Ÿฌํ•œ ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๋ฅผ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•์„ ์•„๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋””๋ฒ„๊น…์„ ์ž˜ํ•˜๋ ค๋ฉด ์–ด๋–ค ์ข…๋ฅ˜์˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์ดํ•ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” Python ์˜ค๋ฅ˜ ์ค‘ ์ผ๋ถ€๋Š” *SyntaxError*, *IndexError*, *NameError*, *ModuleNotFoundError*, *KeyError*, *ImportError*, *AttributeError*, *TypeError*, *ValueError*, *ZeroDivisionError* ๋“ฑ์ž…๋‹ˆ๋‹ค. ์ดํ›„ ์„น์…˜์—์„œ ๋‹ค๋ฅธ Python **_์˜ค๋ฅ˜ ์œ ํ˜•_**์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค. - -Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋” ์—ฐ์Šตํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์ด๋‚˜ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋™ํ•˜์—ฌ **python**์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์”๋‹ˆ๋‹ค. - -![Python Scripting Shell](../images/opening_python_shell.png) - -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์—์„œ ์ฃผ์„์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค - -```shell - # ์ฃผ์„์€ ํ•ด์‹œ๋กœ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. - # (#) ์‹ฌ๋ณผ๋กœ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์€ ํŒŒ์ด์ฌ ์ฃผ์„์ž…๋‹ˆ๋‹ค. -``` - -![Maths on python shell](../images/maths_on_python_shell.png) - -๋‹ค์Œ ์„น์…˜์œผ๋กœ ์ด๋™ํ•˜๊ธฐ ์ „์— Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ๋” ๋งŽ์€ ์—ฐ์Šต์„ ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์…ธ์—์„œ _exit()_๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์—ด๋ฆฐ ์…ธ์„ ๋‹ซ์•˜๋‹ค๊ฐ€ ๋‹ค์‹œ ์—ด์–ด Python ์…ธ์—์„œ ํ…์ŠคํŠธ๋ฅผ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์„ ์—ฐ์Šตํ•ด ๋ด…์‹œ๋‹ค. - -![Writing String on python shell](../images/writing_string_on_shell.png) - -### Visual Studio Code ์„ค์น˜ - -Python ๋Œ€ํ™”ํ˜• ์…ธ์€ ์ž‘์€ ์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ์‹œ๋„ํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•˜๋Š” ๋ฐ ์ ํ•ฉํ•˜์ง€๋งŒ ํฐ ํ”„๋กœ์ ํŠธ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์ž‘์—… ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ์ž๋Š” ๋‹ค์–‘ํ•œ ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด 30์ผ๊ฐ„์˜ Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑŒ๋ฆฐ์ง€์—์„œ๋Š” Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Visual Studio Code๋Š” ๋งค์šฐ ์ธ๊ธฐ ์žˆ๋Š” ์˜คํ”ˆ ์†Œ์Šค ํ…์ŠคํŠธ ํŽธ์ง‘๊ธฐ์ž…๋‹ˆ๋‹ค. ๋‚˜๋Š” vscode์˜ ํŒฌ์ด๊ณ  Visual Studio ์ฝ”๋“œ๋ฅผ [๋‹ค์šด๋กœ๋“œ](https://code.visualstudio.com/)ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•˜๊ณ  ์‹ถ์ง€๋งŒ, ๋‹ค๋ฅธ ํŽธ์ง‘์ž๋ฅผ ์„ ํ˜ธํ•œ๋‹ค๋ฉด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์ž์œ ๋กญ๊ฒŒ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค. - -[![Visual Studio Code](../images/vscode.png)](https://code.visualstudio.com/) - -Visual Studio Code๋ฅผ ์„ค์น˜ํ•˜์…จ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. -๋น„๋””์˜ค๋ฅผ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ Python์šฉ Visual Studio Code[๋น„๋””์˜ค ์ž์Šต์„œ](https://www.youtube.com/watch?v=bn7Cx4z-vSo)๋ฅผ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - -#### visual studio code๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ - -Visual Studio ์•„์ด์ฝ˜์„ ๋‘ ๋ฒˆ ํด๋ฆญํ•˜์—ฌ Visual Studio ์ฝ”๋“œ๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ์—ด๋ฉด ์ด๋Ÿฐ ์ข…๋ฅ˜์˜ ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋ ˆ์ด๋ธ”์ด ์ง€์ •๋œ ์•„์ด์ฝ˜์„ ๋”ฐ๋ผํ•ด๋ณด์„ธ์š”. - -![Visual studio Code](../images/vscode_ui.png) - -๋ฐ”ํƒ• ํ™”๋ฉด์— 30DaysOfPython์ด๋ผ๋Š” ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฝ์‹œ๋‹ค. - -![Opening Project on Visual studio](../images/how_to_open_project_on_vscode.png) - -![Opening a project](../images/opening_project.png) - -ํŒŒ์ผ์„ ์—ด๋ฉด 30DaysOfPython ํ”„๋กœ์ ํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์— ํŒŒ์ผ๊ณผ ํด๋”๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด ์ฒซ ๋ฒˆ์งธ ํŒŒ์ผ์ธ helloworld.py๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ๋„ ๋˜‘๊ฐ™์ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - -![Creating a python file](../images/helloworld.png) - -ํ•˜๋ฃจ๋™์•ˆ ์˜ค๋ž˜ ์ฝ”๋”ฉ์„ ํ•œ ํ›„์— ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ๋ฅผ ๋‹ซ๊ณ  ์‹ถ์Šต๋‹ˆ๊นŒ? ์ด๋ ‡๊ฒŒ ์—ด๋ฆฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ซ์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. - -![Closing project](../images/closing_opened_project.png) - -์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ •์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์„ ์‹œ์ž‘ํ•ด ๋ด…์‹œ๋‹ค. - -## Python ๊ธฐ๋ณธ - -### Python ๊ตฌ๋ฌธ - -Python ์Šคํฌ๋ฆฝํŠธ๋Š” Python ๋Œ€ํ™”ํ˜• ์…ธ ๋˜๋Š” ์ฝ”๋“œ ํŽธ์ง‘๊ธฐ์—์„œ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Python ํŒŒ์ผ์˜ ํ™•์žฅ์ž๋Š” .py์ž…๋‹ˆ๋‹ค. - -### Python ๋“ค์—ฌ ์“ฐ๊ธฐ - -๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ํ…์ŠคํŠธ์˜ ๊ณต๋ฐฑ์ž…๋‹ˆ๋‹ค. ๋งŽ์€ ์–ธ์–ด์—์„œ ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ Python์€ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ๋Š” ์ค‘๊ด„ํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋“ค์—ฌ์“ฐ๊ธฐ ๋Œ€์‹  ์ฝ”๋“œ ๋ธ”๋ก์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. Python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ๋ฒ„๊ทธ ์ค‘ ํ•˜๋‚˜๋Š” ์ž˜๋ชป๋œ ๋“ค์—ฌ์“ฐ๊ธฐ์ž…๋‹ˆ๋‹ค. - -![Indentation Error](../images/indentation.png) - -### ์ฃผ์„ - -์ฃผ์„์€ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ค๊ณ  ์ฝ”๋“œ์— ์„ค๋ช…์„ ๋‚จ๊ธฐ๊ธฐ ์œ„ํ•ด ๋งค์šฐ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. Python์€ ์ฝ”๋“œ์˜ ์ฃผ์„ ๋ถ€๋ถ„์„ ์‹คํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. -Python์—์„œ ํ•ด์‹œ(#)๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ชจ๋“  ํ…์ŠคํŠธ๋Š” ์ฃผ์„์ž…๋‹ˆ๋‹ค. - -**์˜ˆ์‹œ:ํ•œ ๋ฌธ์žฅ ์ฃผ์„** - -```shell - # 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 - -```shell -"""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 - -์ž‘์€๋”ฐ์˜ดํ‘œ ๋˜๋Š” ํฐ๋”ฐ์˜ดํ‘œ ์•„๋ž˜์— ์žˆ๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ๋ฌธ์ž ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์ด ๋‘ ๋ฌธ์žฅ ์ด์ƒ์ธ ๊ฒฝ์šฐ ์‚ผ์ค‘ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. - -**์˜ˆ์‹œ:** - -```py -'Asabeneh' -'Finland' -'Python' -'I love teaching' -'I hope you are enjoying the first day of 30DaysOfPython Challenge' -``` - -#### Boolean - -๋ถ€์šธ ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ True ๋˜๋Š” False ๊ฐ’์ž…๋‹ˆ๋‹ค. T์™€ F๋Š” ํ•ญ์ƒ ๋Œ€๋ฌธ์ž์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. - -**์˜ˆ์‹œ:** - -```python - True # ๋ถˆ์ด ์ผœ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ์ฐธ์ž…๋‹ˆ๋‹ค. - False # ๋ถˆ์ด ๊บผ์ ธ์žˆ๋‚˜์š”? ๊ทธ๋Ÿฌ๋ฉด ๊ฑฐ์ง“์ž…๋‹ˆ๋‹ค. -``` - -#### List - -Python ๋ฆฌ์ŠคํŠธ๋Š” ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ ์œ ํ˜• ํ•ญ๋ชฉ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ ฌ๋œ ์ปฌ๋ ‰์…˜์ž…๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ๋Š” JavaScript์˜ ๋ฐฐ์—ด๊ณผ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค. - -**Example:** - -```py -[0, 1, 2, 3, 4, 5] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ์ˆซ์ž ๋ฆฌ์ŠคํŠธ -['Banana', 'Orange', 'Mango', 'Avocado'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ณผ์ผ) -['Finland','Estonia', 'Sweden','Norway'] # ๋ชจ๋‘ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด ๋ฆฌ์ŠคํŠธ(๊ตญ๊ฐ€) -['Banana', 10, False, 9.81] # ๋ฆฌ์ŠคํŠธ์˜ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜• - ๋ฌธ์ž์—ด, ์ •์ˆ˜, ๋ถ€์šธ ๋ฐ ๋ถ€๋™ ์†Œ์ˆ˜์  -``` - -#### Dictionary - -Python ์‚ฌ์ „ ๊ฐœ์ฒด๋Š” ํ‚ค ๊ฐ’ ์Œ ํ˜•์‹์˜ ์ •๋ ฌ๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. - -**Example:** - -```py -{ -'first_name':'Asabeneh', -'last_name':'Yetayeh', -'country':'Finland', -'age':250, -'is_married':True, -'skills':['JS', 'React', 'Node', 'Python'] -} -``` - -#### Tuple - -ํŠœํ”Œ์€ ๋ชฉ๋ก๊ณผ ๊ฐ™์€ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ์ •๋ ฌ๋œ ๋ชจ์Œ์ด์ง€๋งŒ ํŠœํ”Œ์ด ์ƒ์„ฑ๋˜๋ฉด ์ˆ˜์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ๋“ค์€ ๋ณ€ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. - -**Example:** - -```py -('Asabeneh', 'Pawel', 'Brook', 'Abraham', 'Lidiya') # Names -``` - -```py -('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets -``` - -#### Set - -์ง‘ํ•ฉ์€ ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ์œ ์‚ฌํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ชฉ๋ก ๋ฐ ํŠœํ”Œ๊ณผ ๋‹ฌ๋ฆฌ ์ง‘ํ•ฉ์€ ์ˆœ์„œ๊ฐ€ ์ง€์ •๋œ ํ•ญ๋ชฉ ๋ชจ์Œ์ด ์•„๋‹™๋‹ˆ๋‹ค. ์ˆ˜ํ•™์—์„œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ Python์—์„œ set์€ ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ๋งŒ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. - -์ดํ›„ ์„น์…˜์—์„œ๋Š” ๊ฐ๊ฐ์˜ ๋ชจ๋“  Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. - -**Example:** - -```py -{2, 4, 3, 5} -{3.14, 9.81, 2.7} # order is not important in set -``` - -### ๋ฐ์ดํ„ฐ ํƒ€์ž… ์ฒดํฌ - -ํŠน์ • ๋ฐ์ดํ„ฐ/๋ณ€์ˆ˜์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด **type** ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์–‘ํ•œ Python ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: - -![Checking Data types](../images/checking_data_types.png) - -### Python ํŒŒ์ผ - -๋จผ์ € ํ”„๋กœ์ ํŠธ ํด๋”์ธ 30DaysOfPython์„ ์—ฝ๋‹ˆ๋‹ค. ์ด ํด๋”๊ฐ€ ์—†์œผ๋ฉด 30DaysOfPython์ด๋ผ๋Š” ํด๋” ์ด๋ฆ„์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด ํด๋” ์•ˆ์— helloworld.py๋ผ๋Š” ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด์ œ Visual Studio ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Python ๋Œ€ํ™”ํ˜• ์…ธ์—์„œ ์ˆ˜ํ–‰ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. - -Python ๋Œ€ํ™”ํ˜• ์…ธ์€ **print**๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ธ์‡„ํ–ˆ์ง€๋งŒ Visual Studio ์ฝ”๋“œ์—์„œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ ค๋ฉด ๋‚ด์žฅ ํ•จ์ˆ˜ *print()๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. *print()* ๋‚ด์žฅ ํ•จ์ˆ˜๋Š” *print('arument1', 'argument2', 'argument3')*์™€ ๊ฐ™์ด ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. - -**Example:** - -ํŒŒ์ผ ์ด๋ฆ„์€ helloworld.py. - -```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](../images/running_python_script.png) - -๐ŸŒ• ์ข‹์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 1์ผ์ฐจ ๋„์ „์„ ์™„๋ฃŒํ–ˆ๊ณ  ๋‹น์‹ ์€ ์œ„๋Œ€ํ•œ ์—ฌ์ •์— ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•ด๋ด…์‹œ๋‹ค. - -## ๐Ÿ’ป Exercises - Day 1 - -### Exercise: Level 1 - -1. ์‚ฌ์šฉ ์ค‘์ธ Python ๋ฒ„์ „ ํ™•์ธ -2. Python ๋Œ€ํ™”ํ˜• ์…ธ์„ ์—ด๊ณ  ๋‹ค์Œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ํ”ผ์—ฐ์‚ฐ์ž๋Š” 3๊ณผ 4์ž…๋‹ˆ๋‹ค. - - ๋”ํ•˜๊ธฐ(+) - - ๋นผ๊ธฐ(-) - - ๊ณฑํ•˜๊ธฐ(\*) - - ๋‚˜๋จธ์ง€(%) - - ๋‚˜๋ˆ„๊ธฐ(/) - - ์ง€์ˆ˜(\*\*) - - ์ •์ˆ˜ ๋‚˜๋ˆ„๊ธฐ(//) -3. Python ๋Œ€ํ™”ํ˜• ์…ธ์— ๋ฌธ์ž์—ด์„ ์”๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: - - ์ด๋ฆ„ - - ๊ฐ€์กฑ ์ด๋ฆ„ - - ๊ตญ๊ฐ€ ์ด๋ฆ„ - - I am enjoying 30 days of python -4. ๋‹ค์Œ ๋ฐ์ดํ„ฐ์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.: - - 10 - - 9.8 - - 3.14 - - 4 - 4j - - ['Asabeneh', 'Python', 'Finland'] - - ์ด๋ฆ„ - - ๊ฐ€์กฑ ์ด๋ฆ„ - - ๊ตญ๊ฐ€ ์ด๋ฆ„ - -### 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](https://en.wikipedia.org/wiki/Euclidean_distance#:~:text=In%20mathematics%2C%20the%20Euclidean%20distance,being%20called%20the%20Pythagorean%20distance.) (2, 3) ๊ณผ (10, 8) ์‚ฌ์ด - -๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค ! ๐ŸŽ‰ - -[Day 2 >>](../02_Day_Variables_builtin_functions/02_variables_builtin_functions.md) \ No newline at end of file From f1a3d948b2c264f1bb5bb21e528cea7cf0234d4a Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Fri, 9 Dec 2022 11:25:02 +0900 Subject: [PATCH 6/8] Day 07 10 md --- Korean/07_sets_ko.md | 417 +++++++++++++++++++++++++++++++++++++++ Korean/10_loops_ko.md | 448 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 865 insertions(+) create mode 100644 Korean/07_sets_ko.md create mode 100644 Korean/10_loops_ko.md diff --git a/Korean/07_sets_ko.md b/Korean/07_sets_ko.md new file mode 100644 index 00000000..46092fb7 --- /dev/null +++ b/Korean/07_sets_ko.md @@ -0,0 +1,417 @@ +
30 Days Of Python: Day 7 - Sets Twitter Follow +
+

Author: Asabeneh Yetayeh
Second Edition: July, 2021

+
+ +[<< Day 6](../06_Day_Tuples/06_tuples.md) | [Day 8 >>](../08_Day_Dictionaries/08_dictionaries.md) + +![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png) + +- [๐Ÿ“˜ Day 7](#-day-7) + - [Sets](#sets) + - [์„ธํŠธ ๋งŒ๋“ค๊ธฐ](#์„ธํŠธ-๋งŒ๋“ค๊ธฐ) + - [์„ธํŠธ์˜ ๊ธธ์ด ๊ตฌํ•˜๊ธฐ](#์„ธํŠธ์˜-๊ธธ์ด-๊ตฌํ•˜๊ธฐ) + - [์„ธํŠธ์˜ ํ•ญ๋ชฉ์— ์•ก์„ธ์Šค](#์„ธํŠธ์˜-ํ•ญ๋ชฉ์—-์—‘์„ธ์Šค) + - [ํ•ญ๋ชฉ ํ™•์ธ](#ํ•ญ๋ชฉ-ํ™•์ธ) + - [์„ธํŠธ์— ํ•ญ๋ชฉ ์ถ”๊ฐ€](#์„ธํŠธ์—-ํ•ญ๋ชฉ-์ถ”๊ฐ€) + - [์„ธํŠธ์—์„œ ํ•ญ๋ชฉ ์ œ๊ฑฐ](#์„ธํŠธ์—์„œ-ํ•ญ๋ชฉ-์ œ๊ฑฐ) + - [์„ธํŠธ์˜ ํ•ญ๋ชฉ ์ง€์šฐ๊ธฐ](#์„ธํŠธ์˜-ํ•ญ๋ชฉ-์ง€์šฐ๊ธฐ) + - [์„ธํŠธ ์‚ญ์ œ](#์„ธํŠธ-์‚ญ์ œ) + - [๋ชฉ๋ก์„ ์ง‘ํ•ฉ์œผ๋กœ ๋ณ€ํ™˜](#๋ชฉ๋ก์„-์ง‘ํ•ฉ์œผ๋กœ-๋ณ€ํ™˜) + - [์ง‘ํ•ฉ ๊ฒฐํ•ฉ](#์ง‘ํ•ฉ-๊ฒฐํ•ฉ) + - [๊ต์ฐจ ํ•ญ๋ชฉ ์ฐพ๊ธฐ](#๊ต์ฐจ-ํ•ญ๋ชฉ-์ฐพ๊ธฐ) + - [ํ•˜์œ„ ์ง‘ํ•ฉ ๋ฐ ์ˆ˜ํผ ์ง‘ํ•ฉ ํ™•์ธ](#ํ•˜์œ„-์ง‘ํ•ฉ-๋ฐ-์ˆ˜ํผ-์ง‘ํ•ฉ-ํ™•์ธ) + - [๋‘ ์„ธํŠธ ๊ฐ„์˜ ์ฐจ์ด ํ™•์ธ](#๋‘-์„ธํŠธ-๊ฐ„์˜-์ฐจ์ด-ํ™•์ธ) + - [๋‘ ์ง‘ํ•ฉ ๊ฐ„์˜ ๋Œ€์นญ์  ์ฐจ์ด ์ฐพ๊ธฐ](#๋‘-์ง‘ํ•ฉ-๊ฐ„์˜-๋Œ€์นญ์ -์ฐจ์ด-์ฐพ๊ธฐ) + - [์ง‘ํ•ฉ ๊ฒฐํ•ฉ](#์ง‘ํ•ฉ-๊ฒฐํ•ฉ) + - [๐Ÿ’ป Exercises: Day 7](#-exercises-day-7) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# ๐Ÿ“˜ Day 7 + +## Sets + +์„ธํŠธ๋Š” ํ•ญ๋ชฉ์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ์ดˆ๋“ฑํ•™๊ต ๋˜๋Š” ๊ณ ๋“ฑํ•™๊ต ์ˆ˜ํ•™ ์ˆ˜์—…์œผ๋กœ ๋Œ์•„๊ฐ€๊ฒ ์Šต๋‹ˆ๋‹ค. ์ง‘ํ•ฉ์˜ ์ˆ˜ํ•™ ์ •์˜๋Š” Python์—์„œ๋„ ์ ์šฉ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ง‘ํ•ฉ์€ ์ˆœ์„œ๊ฐ€ ์ง€์ •๋˜์ง€ ์•Š๊ณ  ์ธ๋ฑ์‹ฑ๋˜์ง€ ์•Š์€ ๊ฐœ๋ณ„ ์š”์†Œ์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. Python์—์„œ ์ง‘ํ•ฉ์€ ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ์„ ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋ฉฐ ์ง‘ํ•ฉ ๊ฐ„์— *ํ•ฉ์ง‘ํ•ฉ* , *๊ต์ฐจ* , *์ฐจ์ด* , *๋Œ€์นญ์  ์ฐจ์ด* , *ํ•˜์œ„ ์ง‘ํ•ฉ* , *์ƒ์œ„ ์ง‘ํ•ฉ* ๋ฐ *๋ถ„๋ฆฌ ์ง‘ํ•ฉ* ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +### ์„ธํŠธ ๋งŒ๋“ค๊ธฐ + +์ค‘๊ด„ํ˜ธ {}๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ธํŠธ ๋˜๋Š” *set()* ๋‚ด์žฅ ํ•จ์ˆ˜๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. + +- ๋นˆ ์„ธํŠธ ๋งŒ๋“ค๊ธฐ + +```py +# syntax +st = {} +# or +st = set() +``` + +- ์ดˆ๊ธฐ ํ•ญ๋ชฉ์œผ๋กœ ์„ธํŠธ ๋งŒ๋“ค๊ธฐ + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +``` + +**์˜ˆ์‹œ:** + +```py +# syntax +fruits = {'banana', 'orange', 'mango', 'lemon'} +``` + +### ์„ธํŠธ์˜ ๊ธธ์ด ๊ตฌํ•˜๊ธฐ + +**len()** ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง‘ํ•ฉ์˜ ๊ธธ์ด๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +len(set) +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +len(fruits) +``` + +### ์„ธํŠธ์˜ ํ•ญ๋ชฉ์— ์•ก์„ธ์Šค + +๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•ญ๋ชฉ์— ์•ก์„ธ์Šคํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ฃจํ”„ ์„น์…˜์—์„œ ์ด๊ฒƒ์„ ๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค + +### ํ•ญ๋ชฉ ํ™•์ธ + +๋ชฉ๋ก์— ํ•ญ๋ชฉ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ๋ฉค๋ฒ„์‹ญ ์—ฐ์‚ฐ์ž *์—์„œ* ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +print("Does set st contain item3? ", 'item3' in st) # Does set st contain item3? True +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +print('mango' in fruits ) # True +``` + +### ์„ธํŠธ์— ํ•ญ๋ชฉ ์ถ”๊ฐ€ + +์„ธํŠธ๊ฐ€ ์ƒ์„ฑ๋˜๋ฉด ํ•ญ๋ชฉ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์œผ๋ฉฐ ํ•ญ๋ชฉ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. + +- *add()* ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•˜๋‚˜์˜ ํ•ญ๋ชฉ ์ถ”๊ฐ€ + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +st.add('item5') +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +fruits.add('lime') +``` + +- *update()* ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ ํ•ญ๋ชฉ ์ถ”๊ฐ€ *update()* ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์„ธํŠธ์— ์—ฌ๋Ÿฌ ํ•ญ๋ชฉ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. *update()* ๋Š” ๋ชฉ๋ก ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +st.update(['item5','item6','item7']) +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +vegetables = ('tomato', 'potato', 'cabbage','onion', 'carrot') +fruits.update(vegetables) +``` + +### ์„ธํŠธ์—์„œ ํ•ญ๋ชฉ ์ œ๊ฑฐ + +*remove()* ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง‘ํ•ฉ์—์„œ ํ•ญ๋ชฉ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ญ๋ชฉ์„ ์ฐพ์„ ์ˆ˜ ์—†์œผ๋ฉด *remove()* ๋ฉ”์„œ๋“œ๋Š” ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฏ€๋กœ ํ•ด๋‹น ํ•ญ๋ชฉ์ด ์ฃผ์–ด์ง„ ์ง‘ํ•ฉ์— ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜, *discard()* ๋ฉ”์„œ๋“œ๋Š” ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š์Šต๋‹ˆ๋‹ค. + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +st.remove('item2') +``` + +pop() ๋ฉ”์„œ๋“œ๋Š” ๋ชฉ๋ก์—์„œ ์ž„์˜์˜ ํ•ญ๋ชฉ์„ ์ œ๊ฑฐํ•˜๊ณ  ์ œ๊ฑฐ๋œ ํ•ญ๋ชฉ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +fruits.pop() # removes a random item from the set + +``` + +์ œ๊ฑฐ๋œ ํ•ญ๋ชฉ์— ๊ด€์‹ฌ์ด ์žˆ๋Š” ๊ฒฝ์šฐ. + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +removed_item = fruits.pop() +``` + +### ์„ธํŠธ์˜ ํ•ญ๋ชฉ ์ง€์šฐ๊ธฐ + +์„ธํŠธ๋ฅผ ์ง€์šฐ๊ฑฐ๋‚˜ ๋น„์šฐ๋ ค๋ฉด *clear* ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +st.clear() +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +fruits.clear() +print(fruits) # set() +``` + +### ์„ธํŠธ ์‚ญ์ œ + +์„ธํŠธ ์ž์ฒด๋ฅผ ์‚ญ์ œํ•˜๋ ค๋ฉด *del* ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st = {'item1', 'item2', 'item3', 'item4'} +del st +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +del fruits +``` + +### ๋ชฉ๋ก์„ ์ง‘ํ•ฉ์œผ๋กœ ๋ณ€ํ™˜ + +๋ฆฌ์ŠคํŠธ๋ฅผ ์„ธํŠธ๋กœ, ์„ธํŠธ๋ฅผ ๋ฆฌ์ŠคํŠธ๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชฉ๋ก์„ ์„ธํŠธ๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด ์ค‘๋ณต ํ•ญ๋ชฉ์ด ์ œ๊ฑฐ๋˜๊ณ  ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ๋งŒ ์˜ˆ์•ฝ๋ฉ๋‹ˆ๋‹ค. + +```py +# syntax +lst = ['item1', 'item2', 'item3', 'item4', 'item1'] +st = set(lst) # {'item2', 'item4', 'item1', 'item3'} - the order is random, because sets in general are unordered +``` + +**์˜ˆ์‹œ:** + +```py +fruits = ['banana', 'orange', 'mango', 'lemon','orange', 'banana'] +fruits = set(fruits) # {'mango', 'lemon', 'banana', 'orange'} +``` + +### ์ง‘ํ•ฉ ๊ฒฐํ•ฉ + +*union()* ๋˜๋Š” *update()* ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‘ ์ง‘ํ•ฉ์„ ๊ฒฐํ•ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +- Union ์ด ๋ฉ”์„œ๋“œ๋Š” ์ƒˆ ์ง‘ํ•ฉ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item5', 'item6', 'item7', 'item8'} +st3 = st1.union(st2) +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +vegetables = {'tomato', 'potato', 'cabbage','onion', 'carrot'} +print(fruits.union(vegetables)) # {'lemon', 'carrot', 'tomato', 'banana', 'mango', 'orange', 'cabbage', 'potato', 'onion'} +``` + +- ์—…๋ฐ์ดํŠธ ์ด ๋ฉ”์„œ๋“œ๋Š” ์ฃผ์–ด์ง„ ์ง‘ํ•ฉ์— ์ง‘ํ•ฉ์„ ์‚ฝ์ž…ํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item5', 'item6', 'item7', 'item8'} +st1.update(st2) # st2 contents are added to st1 +``` + +**์˜ˆ์‹œ:** + +```py +fruits = {'banana', 'orange', 'mango', 'lemon'} +vegetables = {'tomato', 'potato', 'cabbage','onion', 'carrot'} +fruits.update(vegetables) +print(fruits) # {'lemon', 'carrot', 'tomato', 'banana', 'mango', 'orange', 'cabbage', 'potato', 'onion'} +``` + +### ๊ต์ฐจ ํ•ญ๋ชฉ ์ฐพ๊ธฐ + +Intersection์€ ๋‘ ์ง‘ํ•ฉ ๋ชจ๋‘์— ์žˆ๋Š” ํ•ญ๋ชฉ ์ง‘ํ•ฉ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item3', 'item2'} +st1.intersection(st2) # {'item3', 'item2'} +``` + +**์˜ˆ์‹œ:** + +```py +whole_numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +even_numbers = {0, 2, 4, 6, 8, 10} +whole_numbers.intersection(even_numbers) # {0, 2, 4, 6, 8, 10} + +python = {'p', 'y', 't', 'h', 'o','n'} +dragon = {'d', 'r', 'a', 'g', 'o','n'} +python.intersection(dragon) # {'o', 'n'} +``` + +### ํ•˜์œ„ ์ง‘ํ•ฉ ๋ฐ ์ˆ˜ํผ ์ง‘ํ•ฉ ํ™•์ธ + +์ง‘ํ•ฉ์€ ๋‹ค๋ฅธ ์ง‘ํ•ฉ์˜ ํ•˜์œ„ ์ง‘ํ•ฉ ๋˜๋Š” ์ƒ์œ„ ์ง‘ํ•ฉ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +- Subset: *issubset()* +- Super set: *issuperset* + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item2', 'item3'} +st2.issubset(st1) # True +st1.issuperset(st2) # True +``` + +**์˜ˆ์‹œ:** + +```py +whole_numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +even_numbers = {0, 2, 4, 6, 8, 10} +whole_numbers.issubset(even_numbers) # False, because it is a super set +whole_numbers.issuperset(even_numbers) # True + +python = {'p', 'y', 't', 'h', 'o','n'} +dragon = {'d', 'r', 'a', 'g', 'o','n'} +python.issubset(dragon) # False +``` + +### ๋‘ ์„ธํŠธ ๊ฐ„์˜ ์ฐจ์ด ํ™•์ธ + +๋‘ ์ง‘ํ•ฉ ๊ฐ„์˜ ์ฐจ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item2', 'item3'} +st2.difference(st1) # set() +st1.difference(st2) # {'item1', 'item4'} => st1\st2 +``` + +**์˜ˆ์‹œ:** + +```py +whole_numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +even_numbers = {0, 2, 4, 6, 8, 10} +whole_numbers.difference(even_numbers) # {1, 3, 5, 7, 9} + +python = {'p', 'y', 't', 'o','n'} +dragon = {'d', 'r', 'a', 'g', 'o','n'} +python.difference(dragon) # {'p', 'y', 't'} - the result is unordered (characteristic of sets) +dragon.difference(python) # {'d', 'r', 'a', 'g'} +``` + +### ๋‘ ์ง‘ํ•ฉ ๊ฐ„์˜ ๋Œ€์นญ์  ์ฐจ์ด ์ฐพ๊ธฐ + +๋‘ ์ง‘ํ•ฉ ๊ฐ„์˜ ๋Œ€์นญ ์ฐจ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜ํ•™์ ์œผ๋กœ ๋‘ ์„ธํŠธ์— ์žˆ๋Š” ํ•ญ๋ชฉ์„ ์ œ์™ธํ•˜๊ณ  ๋‘ ์„ธํŠธ์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์„ ํฌํ•จํ•˜๋Š” ์„ธํŠธ๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. (A\B) โˆช (B\A) + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item2', 'item3'} +# it means (A\B)โˆช(B\A) +st2.symmetric_difference(st1) # {'item1', 'item4'} +``` + +**์˜ˆ์‹œ:** + +```py +whole_numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +some_numbers = {1, 2, 3, 4, 5} +whole_numbers.symmetric_difference(some_numbers) # {0, 6, 7, 8, 9, 10} + +python = {'p', 'y', 't', 'h', 'o','n'} +dragon = {'d', 'r', 'a', 'g', 'o','n'} +python.symmetric_difference(dragon) # {'r', 't', 'p', 'y', 'g', 'a', 'd', 'h'} +``` + +### ์ง‘ํ•ฉ ๊ฒฐํ•ฉ + +๋‘ ์„ธํŠธ์— ๊ณตํ†ต ํ•ญ๋ชฉ์ด ์—†์œผ๋ฉด ๋ถ„๋ฆฌ ์„ธํŠธ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. *isdisjoint()* ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‘ ์ง‘ํ•ฉ์ด ๊ฒฐํ•ฉ์ธ์ง€ ๋ถ„๋ฆฌ์ธ์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py +# syntax +st1 = {'item1', 'item2', 'item3', 'item4'} +st2 = {'item2', 'item3'} +st2.isdisjoint(st1) # False +``` + +**์˜ˆ์‹œ:** + +```py +even_numbers = {0, 2, 4 ,6, 8} +even_numbers = {1, 3, 5, 7, 9} +even_numbers.isdisjoint(odd_numbers) # True, because no common item + +python = {'p', 'y', 't', 'h', 'o','n'} +dragon = {'d', 'r', 'a', 'g', 'o','n'} +python.isdisjoint(dragon) # False, there are common items {'o', 'n'} +``` + +๐ŸŒ• ๋‹น์‹ ์€ ๋– ์˜ค๋ฅด๋Š” ๋ณ„์ž…๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ๋ฐฉ๊ธˆ 7์ผ์ฐจ ์ฑŒ๋ฆฐ์ง€๋ฅผ ์™„๋ฃŒํ–ˆ์œผ๋ฉฐ ์œ„๋Œ€ํ•จ์„ ํ–ฅํ•œ ๋‹น์‹ ์˜ ๊ธธ์— 7๊ฑธ์Œ ์•ž์„œ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ›ˆ๋ จ์„ ํ•˜์‹ญ์‹œ์˜ค. + +## ๐Ÿ’ป Exercises: Day 7 + +```py +# sets +it_companies = {'Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon'} +A = {19, 22, 24, 20, 25, 26} +B = {19, 22, 20, 25, 26, 24, 28, 27} +age = [22, 19, 24, 25, 26, 24, 25, 24] +``` + +### Exercises: Level 1 + +1. ์ง‘ํ•ฉ it_companies์˜ ๊ธธ์ด ์ฐพ๊ธฐ +2. it_companies์— 'Twitter' ์ถ”๊ฐ€ +3. it_companies ์ง‘ํ•ฉ์— ์—ฌ๋Ÿฌ IT ํšŒ์‚ฌ๋ฅผ ํ•œ ๋ฒˆ์— ์‚ฝ์ž… +4. it_companies ์ง‘ํ•ฉ์—์„œ ํšŒ์‚ฌ ์ค‘ ํ•˜๋‚˜๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. +5. ์ œ๊ฑฐํ•˜๋‹ค์™€ ๋ฒ„๋ฆฌ๋‹ค์˜ ์ฐจ์ด์ ์€ ๋ฌด์—‡์ธ๊ฐ€์š”? + +### Exercises: Level 2 + +1. A์™€ B๋ฅผ ๊ฒฐํ•ฉ +2. ๊ต์ฐจ ํ•ญ๋ชฉ ์ฐพ๊ธฐ +3. A๋Š” B์˜ ๋ถ€๋ถ„์ง‘ํ•ฉ +4. A์™€ B๋Š” ์„œ๋กœ์†Œ ์ง‘ํ•ฉ์ž…๋‹ˆ๋‹ค. +5. A๋Š” B์™€, B๋Š” A์™€ ์กฐ์ธ +6. A์™€ B์˜ ๋Œ€์นญ ์ฐจ์ด๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ +7. ์„ธํŠธ๋ฅผ ์™„์ „ํžˆ ์‚ญ์ œ + +### Exercises: Level 3 + +1. ์—ฐ๋ น์„ ์„ธํŠธ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ  ๋ชฉ๋ก์˜ ๊ธธ์ด์™€ ์„ธํŠธ์˜ ๊ธธ์ด๋ฅผ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. ์–ด๋Š ๊ฒƒ์ด ๋” ํฝ๋‹ˆ๊นŒ? +2. ๋ฌธ์ž์—ด, ๋ชฉ๋ก, ํŠœํ”Œ ๋ฐ ์ง‘ํ•ฉ๊ณผ ๊ฐ™์€ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ์ฐจ์ด์ ์„ ์„ค๋ช…ํ•˜์‹ญ์‹œ์˜ค. +3. *์ €๋Š” ๊ต์‚ฌ์ด๊ณ  ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ์˜๊ฐ์„ ์ฃผ๊ณ  ๊ฐ€๋ฅด์น˜๋Š” ๊ฒƒ์„ ์ข‹์•„ํ•ฉ๋‹ˆ๋‹ค.* ๋ฌธ์žฅ์— ์‚ฌ์šฉ๋œ ๋…ํŠนํ•œ ๋‹จ์–ด๋Š” ๋ช‡ ๊ฐœ์ž…๋‹ˆ๊นŒ? ๋ถ„ํ•  ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜๊ณ  ๊ณ ์œ ํ•œ ๋‹จ์–ด๋ฅผ ๊ฐ€์ ธ์˜ค๋„๋ก ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. + +๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค! ๐ŸŽ‰ + +[<< 6์ผ์ฐจ](../06_Day_Tuples/06_tuples.md) | [8์ผ์ฐจ >>](../08_Day_Dictionaries/08_dictionaries.md) diff --git a/Korean/10_loops_ko.md b/Korean/10_loops_ko.md new file mode 100644 index 00000000..8b88fd87 --- /dev/null +++ b/Korean/10_loops_ko.md @@ -0,0 +1,448 @@ +
30 Days Of Python: Day 10 - Loops Twitter Follow +
+

Author: Asabeneh Yetayeh
Second Edition: July, 2021

+
+ +[<< Day 9](../09_Day_Conditionals/09_conditionals.md) | [Day 11 >>](../11_Day_Functions/11_functions.md) + +![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png) + +- [๐Ÿ“˜ Day 10](#-day-10) + - [Loops](#loops) + - [While ๋ฃจํ”„](#while-๋ฃจํ”„) + - [Break ๊ณผ Continue - Part 1](#break-and-continue---part-1) + - [For ๋ฃจํ”„](#for-๋ฃจํ”„) + - [Break ๊ณผ Continue - Part 2](#break-and-continue---part-2) + - [๋ฒ”์œ„ ๊ธฐ๋Šฅ](#๋ฒ”์œ„-๊ธฐ๋Šฅ) + - [์ค‘์ฒฉ For ๋ฃจํ”„](#์ค‘์ฒฉ-for-๋ฃจํ”„) + - [For Else](#for-else) + - [Pass](#pass) + - [๐Ÿ’ป Exercises: Day 10](#-exercises-day-10) + - [Exercises: Level 1](#exercises-level-1) + - [Exercises: Level 2](#exercises-level-2) + - [Exercises: Level 3](#exercises-level-3) + +# ๐Ÿ“˜ Day 10 + +## Loops + +์ธ์ƒ์€ ์ผ์ƒ์œผ๋กœ ๊ฐ€๋“ ์ฐจ ์žˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ์šฐ๋ฆฌ๋Š” ๋˜ํ•œ ๋งŽ์€ ๋ฐ˜๋ณต ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ˜๋ณต ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋Š” ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋Š” ๋˜ํ•œ ๋‹ค์Œ ์œ ํ˜•์˜ ๋‘ ๋ฃจํ”„๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. + +1. while loop +2. for loop + +### While ๋ฃจํ”„ + +์šฐ๋ฆฌ๋Š” while ๋ฃจํ”„๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์˜ˆ์•ฝ์–ด *while* ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ฃผ์–ด์ง„ ์กฐ๊ฑด์ด ๋งŒ์กฑ๋  ๋•Œ๊นŒ์ง€ ๋ฌธ ๋ธ”๋ก์„ ๋ฐ˜๋ณต์ ์œผ๋กœ ์‹คํ–‰ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์กฐ๊ฑด์ด ๊ฑฐ์ง“์ด ๋˜๋ฉด ๋ฃจํ”„ ๋’ค์˜ ์ฝ”๋“œ ํ–‰์ด ๊ณ„์† ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. + +```py + # syntax +while condition: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +count = 0 +while count < 5: + print(count) + count = count + 1 +#prints from 0 to 4 +``` + +์œ„์˜ while ๋ฃจํ”„์—์„œ count๊ฐ€ 5์ผ ๋•Œ ์กฐ๊ฑด์ด false๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. ์ด๋•Œ ๋ฃจํ”„๊ฐ€ ์ค‘์ง€๋ฉ๋‹ˆ๋‹ค. ์กฐ๊ฑด์ด ๋” ์ด์ƒ ์ฐธ์ด ์•„๋‹ ๋•Œ ์ฝ”๋“œ ๋ธ”๋ก์„ ์‹คํ–‰ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด *else* ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py + # syntax +while condition: + code goes here +else: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +count = 0 +while count < 5: + print(count) + count = count + 1 +#prints from 0 to 4 +``` + +์œ„์˜ ๋ฃจํ”„ ์กฐ๊ฑด์€ count๊ฐ€ 5์ด๊ณ  ๋ฃจํ”„๊ฐ€ ์ค‘์ง€๋˜๊ณ  ์‹คํ–‰์ด else ๋ฌธ์„ ์‹œ์ž‘ํ•˜๋ฉด ๊ฑฐ์ง“์ด ๋ฉ๋‹ˆ๋‹ค. ๊ฒฐ๊ณผ์ ์œผ๋กœ 5๊ฐ€ ์ธ์‡„๋ฉ๋‹ˆ๋‹ค. + +### Break ๊ณผ Continue - Part 1 + +- ์ค‘๋‹จ: ๋ฃจํ”„์—์„œ ๋ฒ—์–ด๋‚˜๊ฑฐ๋‚˜ ์ค‘๋‹จํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์ค‘๋‹จ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +while condition: + code goes here + if another_condition: + break +``` + +**์˜ˆ์‹œ:** + +```py +count = 0 +while count < 5: + print(count) + count = count + 1 + if count == 3: + break +``` + +์œ„์˜ while ๋ฃจํ”„๋Š” 0, 1, 2๋งŒ ์ธ์‡„ํ•˜์ง€๋งŒ 3์— ๋„๋‹ฌํ•˜๋ฉด ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค. + +- ๊ณ„์†: continue ๋ฌธ์„ ์‚ฌ์šฉํ•˜๋ฉด ํ˜„์žฌ ๋ฐ˜๋ณต์„ ๊ฑด๋„ˆ๋›ฐ๊ณ  ๋‹ค์Œ์„ ๊ณ„์†ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py + # syntax +while condition: + code goes here + if another_condition: + continue +``` + +**์˜ˆ์‹œ:** + +```py +count = 0 +while count < 5: + if count == 3: + continue + print(count) + count = count + 1 +``` + +์œ„์˜ while ๋ฃจํ”„๋Š” 0, 1, 2 ๋ฐ 4๋งŒ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค(3์„ ๊ฑด๋„ˆ๋œ๋‹ˆ๋‹ค). + +### For ๋ฃจํ”„ + +*for* ํ‚ค์›Œ๋“œ๋Š” ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์™€ ์œ ์‚ฌํ•˜์ง€๋งŒ ๊ตฌ๋ฌธ์ด ์•ฝ๊ฐ„ ๋‹ค๋ฅธ for ๋ฃจํ”„๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋ฃจํ”„๋Š” ์‹œํ€€์Šค(์ฆ‰, ๋ชฉ๋ก, ํŠœํ”Œ, ์‚ฌ์ „, ์ง‘ํ•ฉ ๋˜๋Š” ๋ฌธ์ž์—ด)๋ฅผ ๋ฐ˜๋ณตํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. + +- For loop with list + +```py +# syntax +for iterator in lst: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +numbers = [0, 1, 2, 3, 4, 5] +for number in numbers: # number is temporary name to refer to the list's items, valid only inside this loop + print(number) # the numbers will be printed line by line, from 0 to 5 +``` + +- For loop with string + +```py +# syntax +for iterator in string: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +language = 'Python' +for letter in language: + print(letter) + + +for i in range(len(language)): + print(language[i]) +``` + +- For loop with tuple + +```py +# syntax +for iterator in tpl: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +numbers = (0, 1, 2, 3, 4, 5) +for number in numbers: + print(number) +``` + +- ์‚ฌ์ „์„ ์‚ฌ์šฉํ•œ For ๋ฃจํ”„ ์‚ฌ์ „์„ ํ†ตํ•œ ๋ฃจํ”„๋Š” ์‚ฌ์ „์˜ ํ‚ค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. + +```py + # syntax +for iterator in dct: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +person = { + 'first_name':'Asabeneh', + 'last_name':'Yetayeh', + 'age':250, + 'country':'Finland', + 'is_marred':True, + 'skills':['JavaScript', 'React', 'Node', 'MongoDB', 'Python'], + 'address':{ + 'street':'Space street', + 'zipcode':'02210' + } +} +for key in person: + print(key) + +for key, value in person.items(): + print(key, value) # this way we get both keys and values printed out +``` + +- Loops in set + +```py +# syntax +for iterator in st: + code goes here +``` + +**์˜ˆ์‹œ:** + +```py +it_companies = {'Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon'} +for company in it_companies: + print(company) +``` + +### Break ๊ณผ Continue - Part 2 + +์งง์€ ์•Œ๋ฆผ: *์ค‘๋‹จ* : ๋ฃจํ”„๊ฐ€ ์™„๋ฃŒ๋˜๊ธฐ ์ „์— ์ค‘๋‹จํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์ค‘๋‹จ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +for iterator in sequence: + code goes here + if condition: + break +``` + +**์˜ˆ์‹œ:** + +```py +numbers = (0,1,2,3,4,5) +for number in numbers: + print(number) + if number == 3: + break +``` + +์œ„์˜ ์˜ˆ์—์„œ ๋ฃจํ”„๋Š” 3์— ๋„๋‹ฌํ•˜๋ฉด ์ค‘์ง€๋ฉ๋‹ˆ๋‹ค. + +๊ณ„์†: ๋ฃจํ”„ ๋ฐ˜๋ณต์—์„œ ์ผ๋ถ€ ๋‹จ๊ณ„๋ฅผ ๊ฑด๋„ˆ๋›ฐ๊ณ  ์‹ถ์„ ๋•Œ ๊ณ„์†์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py + # syntax +for iterator in sequence: + code goes here + if condition: + continue +``` + +**์˜ˆ์‹œ:** + +```py +numbers = (0,1,2,3,4,5) +for number in numbers: + print(number) + if number == 3: + continue + print('Next number should be ', number + 1) if number != 5 else print("loop's end") # for short hand conditions need both if and else statements +print('outside the loop') +``` + +์œ„์˜ ์˜ˆ์—์„œ ์ˆซ์ž๊ฐ€ 3์ด๋ฉด ์กฐ๊ฑด *๋‹ค์Œ* ๋‹จ๊ณ„(๋ฃจํ”„ ๋‚ด๋ถ€)๋ฅผ ๊ฑด๋„ˆ๋›ฐ๊ณ  ๋ฐ˜๋ณต์ด ๋‚จ์•„ ์žˆ์œผ๋ฉด ๋ฃจํ”„ ์‹คํ–‰์ด ๊ณ„์†๋ฉ๋‹ˆ๋‹ค. + +### ๋ฒ”์œ„ ๊ธฐ๋Šฅ + +*range()* ํ•จ์ˆ˜๋Š” ์ˆซ์ž ๋ชฉ๋ก์— ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. *๋ฒ”์œ„(์‹œ์ž‘, ๋, ๋‹จ๊ณ„)* ๋Š” ์‹œ์ž‘, ์ข…๋ฃŒ ๋ฐ ์ฆ๋ถ„์˜ ์„ธ ๊ฐ€์ง€ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๊ณ  ์ฆ๋ถ„์€ 1์ž…๋‹ˆ๋‹ค. ๋ฒ”์œ„ ์‹œํ€€์Šค์—๋Š” ์ตœ์†Œ 1๊ฐœ์˜ ์ธ์ˆ˜(์ข…๋ฃŒ)๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋ฒ”์œ„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‹œํ€€์Šค ๋งŒ๋“ค๊ธฐ + +```py +lst = list(range(11)) +print(lst) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +st = set(range(1, 11)) # 2 arguments indicate start and end of the sequence, step set to default 1 +print(st) # {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + +lst = list(range(0,11,2)) +print(lst) # [0, 2, 4, 6, 8, 10] +st = set(range(0,11,2)) +print(st) # {0, 2, 4, 6, 8, 10} +``` + +```py +# syntax +for iterator in range(start, end, step): +``` + +**์˜ˆ์‹œ:** + +```py +for number in range(11): + print(number) # prints 0 to 10, not including 11 +``` + +### ์ค‘์ฒฉ For ๋ฃจํ”„ + +๋ฃจํ”„ ์•ˆ์— ๋ฃจํ”„๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +```py +# syntax +for x in y: + for t in x: + print(t) +``` + +**์˜ˆ์‹œ:** + +```py +person = { + 'first_name': 'Asabeneh', + 'last_name': 'Yetayeh', + 'age': 250, + 'country': 'Finland', + 'is_marred': True, + 'skills': ['JavaScript', 'React', 'Node', 'MongoDB', 'Python'], + 'address': { + 'street': 'Space street', + 'zipcode': '02210' + } +} +for key in person: + if key == 'skills': + for skill in person['skills']: + print(skill) +``` + +### For Else + +๋ฃจํ”„๊ฐ€ ๋๋‚  ๋•Œ ๋ฉ”์‹œ์ง€๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด else๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + +```py +# syntax +for iterator in range(start, end, step): + do something +else: + print('The loop ended') +``` + +**์˜ˆ์‹œ:** + +```py +for number in range(11): + print(number) # prints 0 to 10, not including 11 +else: + print('The loop stops at', number) +``` + +### Pass + +Python์—์„œ when ๋ฌธ์ด ํ•„์š”ํ•˜์ง€๋งŒ(์„ธ๋ฏธ์ฝœ๋ก  ๋’ค์—) ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์„ ์ข‹์•„ํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์˜ค๋ฅ˜๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด *pass* ๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ํ–ฅํ›„ ์ง„์ˆ ์„ ์œ„ํ•ด ์ž๋ฆฌ ํ‘œ์‹œ์ž๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. + +**์˜ˆ์‹œ:** + +```py +for number in range(6): + pass +``` + +๐ŸŒ• ๋‹น์‹ ์€ ํฐ ์ด์ •ํ‘œ๋ฅผ ์„ธ์› ๊ณ , ๋‹น์‹ ์€ ๋ฉˆ์ถœ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ณ„์†ํ•˜์„ธ์š”! 10์ผ์ฐจ ์ฑŒ๋ฆฐ์ง€๋ฅผ ๋ฐฉ๊ธˆ ์™„๋ฃŒํ–ˆ์œผ๋ฉฐ ์œ„๋Œ€ํ•จ์„ ํ–ฅํ•œ 10๋‹จ๊ณ„๋ฅผ ์•ž๋‘๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๋‡Œ์™€ ๊ทผ์œก์„ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ์šด๋™์„ ํ•˜์‹ญ์‹œ์˜ค. + +## ๐Ÿ’ป Exercises: Day 10 + +### Exercises: Level 1 + +1. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 0์—์„œ 10๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๊ณ  while ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋™์ผํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. + +2. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 10์—์„œ 0๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๊ณ  while ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋™์ผํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. + +3. print()๋ฅผ 7๋ฒˆ ํ˜ธ์ถœํ•˜๋Š” ๋ฃจํ”„๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ๋‹ค์Œ ์‚ผ๊ฐํ˜•์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. + + ```py + # + ## + ### + #### + ##### + ###### + ####### + ``` + +4. ์ค‘์ฒฉ ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. + + ```sh + # # # # # # # # + # # # # # # # # + # # # # # # # # + # # # # # # # # + # # # # # # # # + # # # # # # # # + # # # # # # # # + # # # # # # # # + ``` + +5. ๋‹ค์Œ ํŒจํ„ด์„ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค. + + ```sh + 0 x 0 = 0 + 1 x 1 = 1 + 2 x 2 = 4 + 3 x 3 = 9 + 4 x 4 = 16 + 5 x 5 = 25 + 6 x 6 = 36 + 7 x 7 = 49 + 8 x 8 = 64 + 9 x 9 = 81 + 10 x 10 = 100 + ``` + +6. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ['Python', 'Numpy','Pandas','Django', 'Flask'] ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๊ณ  ํ•ญ๋ชฉ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. + +7. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 0์—์„œ 100๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๊ณ  ์ง์ˆ˜๋งŒ ์ถœ๋ ฅ + +8. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 0์—์„œ 100๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๊ณ  ํ™€์ˆ˜๋งŒ ์ถœ๋ ฅ + +### Exercises: Level 2 + +1. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 0์—์„œ 100๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๊ณ  ๋ชจ๋“  ์ˆซ์ž์˜ ํ•ฉ๊ณ„๋ฅผ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค. + +```sh +The sum of all numbers is 5050. +``` + +1. for ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 0์—์„œ 100๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๊ณ  ๋ชจ๋“  ์ง์ˆ˜์˜ ํ•ฉ๊ณผ ๋ชจ๋“  ์Šน์‚ฐ์˜ ํ•ฉ์„ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค. + + ```sh + The sum of all evens is 2550. And the sum of all odds is 2500. + ``` + +### Exercises: Level 3 + +1. ๋ฐ์ดํ„ฐ ํด๋”๋กœ ์ด๋™ํ•˜์—ฌ [countries.py](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/data/countries.py) ํŒŒ์ผ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๊ตญ๊ฐ€๋ฅผ ์ˆœํ™˜ํ•˜๊ณ  ๋‹จ์–ด *land* ๋ฅผ ํฌํ•จํ•˜๋Š” ๋ชจ๋“  ๊ตญ๊ฐ€๋ฅผ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค. +2. ์ด๊ฒƒ์€ ๊ณผ์ผ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค. ['banana', 'orange', 'mango', 'lemon'] ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ˆœ์„œ๋ฅผ ๋’ค์ง‘์Šต๋‹ˆ๋‹ค. +3. ๋ฐ์ดํ„ฐ ํด๋”๋กœ ์ด๋™ํ•˜์—ฌ [countries_data.py](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/data/countries-data.py) ํŒŒ์ผ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. + 1. ๋ฐ์ดํ„ฐ์˜ ์ด ์–ธ์–ด ์ˆ˜๋Š” ์–ผ๋งˆ์ž…๋‹ˆ๊นŒ? + 2. ๋ฐ์ดํ„ฐ์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” 10๊ฐœ ์–ธ์–ด ์ฐพ๊ธฐ + 3. ์„ธ๊ณ„์—์„œ ์ธ๊ตฌ๊ฐ€ ๊ฐ€์žฅ ๋งŽ์€ 10๊ฐœ ๊ตญ๊ฐ€ ์ฐพ๊ธฐ + +๐ŸŽ‰ ์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค! ๐ŸŽ‰ + +[<< Day 9](../09_Day_Conditionals/09_conditionals.md) | [Day 11 >>](../11_Day_Functions/11_functions.md) From 1f2f42bf527f36a4cb6691334ebb0f095e80bc4a Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Fri, 9 Dec 2022 11:27:47 +0900 Subject: [PATCH 7/8] Day 07 10 md --- Korean/04_strings_ko.md | 2 +- Korean/07_sets_ko.md | 2 +- Korean/10_loops_ko.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Korean/04_strings_ko.md b/Korean/04_strings_ko.md index b2d92dee..dc74f7c3 100644 --- a/Korean/04_strings_ko.md +++ b/Korean/04_strings_ko.md @@ -1,5 +1,5 @@
- 30 Days Of Python: Day 4 - Strings Twitter Follow +

30 Days Of Python: Day 4 - Strings

Twitter Follow

Author: Asabeneh Yetayeh
Second Edition: July, 2021

diff --git a/Korean/07_sets_ko.md b/Korean/07_sets_ko.md index 46092fb7..815f51e2 100644 --- a/Korean/07_sets_ko.md +++ b/Korean/07_sets_ko.md @@ -1,4 +1,4 @@ -
30 Days Of Python: Day 7 - Sets Twitter Follow +

30 Days Of Python: Day 7 - Sets

Twitter Follow

Author: Asabeneh Yetayeh
Second Edition: July, 2021

diff --git a/Korean/10_loops_ko.md b/Korean/10_loops_ko.md index 8b88fd87..408d943c 100644 --- a/Korean/10_loops_ko.md +++ b/Korean/10_loops_ko.md @@ -1,4 +1,4 @@ -
30 Days Of Python: Day 10 - Loops Twitter Follow +

30 Days Of Python: Day 10 - Loops

Twitter Follow

Author: Asabeneh Yetayeh
Second Edition: July, 2021

From 3670b7000e417437d909efd8e2882235eb599a30 Mon Sep 17 00:00:00 2001 From: jshyun1 Date: Fri, 9 Dec 2022 11:32:23 +0900 Subject: [PATCH 8/8] kor ver --- Korean/04_strings_ko.md | 26 +++++++++++++------------- Korean/10_loops_ko.md | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Korean/04_strings_ko.md b/Korean/04_strings_ko.md index dc74f7c3..a5e1d774 100644 --- a/Korean/04_strings_ko.md +++ b/Korean/04_strings_ko.md @@ -10,20 +10,20 @@ - [Day 4](#day-4) - [๋ฌธ์ž์—ด](#strings) - - [๋ฌธ์ž์—ด ๋งŒ๋“ค๊ธฐ](#creating-a-string) - - [๋ฌธ์ž์—ด ์—ฐ๊ฒฐ](#string-concatenation) - - [๋ฌธ์ž์—ด์˜ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค](#escape-sequences-in-strings) - - [๋ฌธ์ž์—ด ํฌ๋งคํŒ…](#string-formatting) - - [์˜ฌ๋“œ ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํฌ๋งคํŒ…(% ์—ฐ์‚ฐ์ž)](#old-style-string-formatting--operator) - - [์ƒˆ๋กœ์šด ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํฌ๋งคํŒ…(str.format)](#new-style-string-formatting-strformat) + - [๋ฌธ์ž์—ด ๋งŒ๋“ค๊ธฐ](#๋ฌธ์ž์—ด-๋งŒ๋“ค๊ธฐ) + - [๋ฌธ์ž์—ด ์—ฐ๊ฒฐ](#๋ฌธ์ž์—ด-์—ฐ๊ฒฐ) + - [๋ฌธ์ž์—ด์˜ ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค](#๋ฌธ์ž์—ด์˜-์ด์Šค์ผ€์ดํ”„-์‹œํ€€์Šค) + - [๋ฌธ์ž์—ด ํฌ๋งคํŒ…](#๋ฌธ์ž์—ด-ํฌ๋งคํŒ…) + - [์˜ฌ๋“œ ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํฌ๋งคํŒ…(% ์—ฐ์‚ฐ์ž)](#์˜ฌ๋“œ-์Šคํƒ€์ผ-๋ฌธ์ž์—ด-ํฌ๋งคํŒ…%-์—ฐ์‚ฐ์ž) + - [์ƒˆ๋กœ์šด ์Šคํƒ€์ผ ๋ฌธ์ž์—ด ํฌ๋งคํŒ…(str.format)](#์ƒˆ๋กœ์šด-์Šคํƒ€์ผ-๋ฌธ์ž์—ด-ํฌ๋งคํŒ…str.format) - [๋ฌธ์ž์—ด Interpolation / f-Strings (Python 3.6+)](#string-interpolation--f-strings-python-36) - - [๋ฌธ์ž ์‹œํ€€์Šค๋กœ์„œ์˜ Python ๋ฌธ์ž์—ด](#python-strings-as-sequences-of-characters) - - [์–ธํŒจํ‚น ๋ฌธ์ž](#unpacking-characters) - - [์ธ๋ฑ์Šค๋กœ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž์— ์•ก์„ธ์Šค](#accessing-characters-in-strings-by-index) - - [ํŒŒ์ด์ฌ ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑ](#slicing-python-strings) - - [๋ฌธ์ž์—ด ๋ฆฌ๋ฒ„์Šค](#reversing-a-string) - - [์Šฌ๋ผ์ด์‹ฑํ•˜๋Š” ๋™์•ˆ ๋ฌธ์ž ๊ฑด๋„ˆ๋›ฐ๊ธฐ](#skipping-characters-while-slicing) - - [๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ](#string-methods) + - [๋ฌธ์ž ์‹œํ€€์Šค๋กœ์„œ์˜ Python ๋ฌธ์ž์—ด](#๋ฌธ์ž-์‹œํ€€์Šค๋กœ์„œ์˜-Python-๋ฌธ์ž์—ด) + - [์–ธํŒจํ‚น ๋ฌธ์ž](#์–ธํŒจํ‚น-๋ฌธ์ž) + - [์ธ๋ฑ์Šค๋กœ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž์— ์•ก์„ธ์Šค](#์ธ๋ฑ์Šค๋กœ-๋ฌธ์ž์—ด์˜-๋ฌธ์ž์—-์•ก์„ธ์Šค) + - [ํŒŒ์ด์ฌ ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑ](#ํŒŒ์ด์ฌ-๋ฌธ์ž์—ด-์Šฌ๋ผ์ด์‹ฑ) + - [๋ฌธ์ž์—ด ๋ฆฌ๋ฒ„์Šค](#๋ฌธ์ž์—ด-๋ฆฌ๋ฒ„์Šค) + - [์Šฌ๋ผ์ด์‹ฑํ•˜๋Š” ๋™์•ˆ ๋ฌธ์ž ๊ฑด๋„ˆ๋›ฐ๊ธฐ](#์Šฌ๋ผ์ด์‹ฑํ•˜๋Š”-๋™์•ˆ-๋ฌธ์ž-๊ฑด๋„ˆ๋›ฐ๊ธฐ) + - [๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ](#๋ฌธ์ž์—ด-๋ฉ”์„œ๋“œ) - [๐Ÿ’ป Exercises - Day 4](#-exercises---day-4) # Day 4 diff --git a/Korean/10_loops_ko.md b/Korean/10_loops_ko.md index 408d943c..0b6f58d9 100644 --- a/Korean/10_loops_ko.md +++ b/Korean/10_loops_ko.md @@ -10,9 +10,9 @@ - [๐Ÿ“˜ Day 10](#-day-10) - [Loops](#loops) - [While ๋ฃจํ”„](#while-๋ฃจํ”„) - - [Break ๊ณผ Continue - Part 1](#break-and-continue---part-1) + - [Break ๊ณผ Continue - Part 1](#break-๊ณผ-continue---part-1) - [For ๋ฃจํ”„](#for-๋ฃจํ”„) - - [Break ๊ณผ Continue - Part 2](#break-and-continue---part-2) + - [Break ๊ณผ Continue - Part 2](#break-๊ณผ-continue---part-2) - [๋ฒ”์œ„ ๊ธฐ๋Šฅ](#๋ฒ”์œ„-๊ธฐ๋Šฅ) - [์ค‘์ฒฉ For ๋ฃจํ”„](#์ค‘์ฒฉ-for-๋ฃจํ”„) - [For Else](#for-else)