or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →01.Python_basic基礎
我們先來認識所謂「程式」的基礎吧
程式的組成
建立Python環境
以下方法擇一皆可
官網下載Python: https://www.python.org/
開啟Google的Colab
安裝ANACONDA:
0.Python的變數
1.立馬進行基本計算
加減乘除非常方便,直接進行即可
2.輕鬆上手資料型態
基本資料型態在python指的是整數int、浮點數float(就是小數)、字串str(文字)、布林bool(True or False)
想知道手上資料的型態,可以用type()來確認
Question1
Question2
3.快速使用輸入與輸出
輸出以print()把資料印出來
輸入就以input()讓使用者使用
在jupyter notebook,每個cell最後一個print()可以省略
print()
4.第一個動手做:計算BMI
5.條件判斷
6.必須知道什麼是串列list
切片
7.第二個動手做:線上遊戲命名產生器
80%玩家表示,最花時間的就是命名,既然我們學會了串列list,那我們來嘗試做一個命名產生器
首先以list把地點跟明星名字存起來
用亂數取出一組組合,加在一起組成新的list,最後在取出list內容將字串合在一起
不命名變數也可以,方法百百種,python很自由
8.kv配對的字典
9.條件判斷II:如果,否則
可以分成
現學現賣之「智慧聊天機器人」
10.人生就是迴圈
迴圈是程式語言的特徵,讓電腦協助你重覆執行某項判斷,主流用法就是for迴圈與while迴圈,另外python還有一個枚舉可以使用。
10-1 For迴圈
10-2 enumerate()枚舉
假設我們要迭代list成員的名稱,並獲取list中每個成員的位置。可以用enumerate,又稱枚舉
10-3 while迴圈
while迴圈,除非成立才會跳出循環
*現學現賣之「金庫密碼」
11.函數其實很精彩
用來打包你所會的一切,必要時呼叫出來就可以用
呼叫時使用
12.第三個動手做:打造訂餐系統
當程式以函數包起來後,使用者只要呼叫函數,輸入對應的引數,即可得到結果,不需要在意裡面的細節囉
13.用來個翻譯吧
來體驗怎麼使用外部模組
13-2.Python google翻譯
python google 翻譯
13-2. 翻譯轉語音
python google 文字轉語音
13-3.把翻譯+語音串起來
reference