> For the complete documentation index, see [llms.txt](https://jirlong.gitbook.io/py/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jirlong.gitbook.io/py/master.md).

# Instruction (80%)

##

## 2. 開始跟著課程寫程式

### 2.1 開啟jupyter notebook

1. **下載課程內容**: Download materials from <https://github.com/P4CSS/PSS107> unzip and remember the location of it on your computer
2. **開啟jupyter notebook**: 開啟**cmd.exe** (wins) 或**terminal.app** (osx)，並輸&#x5165;**`jupyter notebook`** 以啟動他。也可以打開Anaconda Navigator，然後選擇Jupyter notebook執行它。
3. 啟動後命令視窗（cmd.exe或terminal.app）會出現一段有token的網址，請記得有這回事，當不小心關掉所有視窗後，只要用這段網址貼在網址列就可以重新打開jupyter notebook。

![open cmd.exe (wins) or terminal.app (osx), type jupyter notebook to start it](/files/-M3jPIkUOSlUb-dVDVvr)

![Open Anaconda-Navigator then Start the jupyter notebook](/files/-M3jQdNAtmzr_51mhjUZ)

![Copy/paste the URL into your browser to open the jupyter notebook](/files/-M3jRHCTdX33kdEKAnzN)

### 2.2 快速鍵jupyter notebook

* `Shift + Enter` run the current cell, select below
* `Ctrl + Enter` run selected cells
* `Alt + Enter` run the current cell, insert below
* `Ctrl + S` save and checkpoint
* `Enter` take you into edit mode
* `D, D (press the key twice)` delete selected cells
* `Esc` take you into command mode
* `Y` change the cell type to *Code*
* `M` change the cell type to *Markdown*
* `A` insert cell above
* `B` insert cell below

### 2.3 jupyter lab

建議jupyter notebook的使用者可直接改用jupyter lab，用法和jupyter notebook一樣，又可以讓存取檔案、操作資料變的更方便。打開Anaconda-Navigator就可以找到JupyterLab

![](/files/-MUHtoDv1DcLTXAhQl_5)

或者直接在Command Line輸入jupyter lab就可以啟動。

![](/files/-MUHuB61MPgKZzrOCQ91)

啟動後的結果如下圖，編輯起來跟jupyter notebook一樣。

![](/files/-MUHuQmi573Km4iKxs2D)

## 3. 課程學習指引

由於我建立這個gitbook的目的是授課，我提供以下學習材料，是我課堂中必要或者延伸教材。

### 主要學習教材：Youtube&#x20;

Youtube的內容主要是沿著這個gitbook pyTutorial來講解，大部分的code都會和gitbook一樣，但gitbook可能會有一些章節內容有更新，Youtube則可能抽出一些額外單元獨立出來講（例如Sorting）。建議是跟著gitbook重頭打起，或者將github上[pyTutorial](https://github.com/P4CSS/pyTutorial)這個repo複製到自己的電腦中。

{% embed url="<https://www.youtube.com/playlist?list=PLK0n8HKZQ_Vfq0zj6leu24T3TJudwXMzA>" %}

#### Section 1: Basic operations

#### Section 2: Counding

#### Section 3: List and dictionary

#### Section 4 and 5: Condition and Flow

* [\[py\_if\_for\] 01 Concept and AQI case introduction](https://youtu.be/ayBi8pfJjIY): if與for的語法說明和使用以及AQI的案例說明[ ](https://youtu.be/ayBi8pfJjIY)
* [\[py\_if\_for\] 02 Accessing AQI data](https://youtu.be/uWIiAZBIbM4): 探索AQI資料（JSON）的內容結構
* [\[py\_if\_for\] 03 Categorizing and rescaling](https://youtu.be/9rUx0LlUpFM): 依照不同數值區間給予標籤，以空污為例
* [\[pf\_if\_for\] 04 Detect prominent: Finding maximum](https://youtu.be/5-F3d_M_htc): 用for-loop找到一個list中的最大值
* [\[py\_if\_for\] 05 Sorting manually by for, if, swap, list and dict](https://youtu.be/uGMtUr5kt3E): 自己打造一個排序演算法：使用兩層的for-loop、if、調換Swap技巧、以及list和dict結構

### 輔助教材

設計教材的時候我習慣以案例為出發點來帶技術，所以我可能不會花很多時間去解釋例如資料型態、for或者if是什麼這樣的問題。因此我認為Datacamp是本課程最佳的輔助學習教材，他能夠透過互動的方式讓你了解基本的語法與操作。但是Datacamp的使用每個月是需要錢的，如果是課堂上的學生我們通常會幫忙申請教育版。以下這個網站把Datacamp的內容給複製到網頁外，可以速覽一下Datacamp上介紹Python基本語法的內容：<https://www.learnpython.org/>

* [Variables and Types](https://www.learnpython.org/en/Variables_and_Types)
* [Lists](https://www.learnpython.org/en/Lists)
* [Basic Operators](https://www.learnpython.org/en/Basic_Operators)
* [String Formatting](https://www.learnpython.org/en/String_Formatting)
* [Basic String Operations](https://www.learnpython.org/en/Basic_String_Operations)
* [Conditions](https://www.learnpython.org/en/Conditions)
* [Loops](https://www.learnpython.org/en/Loops)
* [Functions](https://www.learnpython.org/en/Functions)
* [Classes and Objects](https://www.learnpython.org/en/Classes_and_Objects)
* [Dictionaries](https://www.learnpython.org/en/Dictionaries)
* [Modules and Packages](https://www.learnpython.org/en/Modules_and_Packages)

## 4. 自學資源

### 線上互動學習平台

* <https://www.learnpython.org/> - Cover the interactive python tutorial of datacamp

### 免費電子書

* Recommendation <https://github.com/juskaiser/FARCON_NLP/blob/master/Resources.md>
* Ebook on safari <https://learning.oreilly.com/library/view/applied-text-analysis/9781491963036/ch01.html>

### 參考資源

* Python document <https://docs.python.org/3.8/tutorial/index.html>

### 好用的github repo

* Applied Text Analysis with Python: <https://github.com/foxbook/atap>
