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
---
Python Tutorial 🐍
Chapter 0
📍
GMJH
⏱
2023/07/10
~2023/07/13
Basic Topic
Labs
Advances Topic
Before we start …
Slido
1. About me
2. Tools
3. Warm up
About me 👋
Jason
成大資工 大一
拔草武陵高中
打工仔GMJH
我碰過什麼
問都問 🙌
Tools ⚙️
Development Setup
設定我們的開發環境!
安裝教學 🔗
Replit
zerojudge
Warm up 🔥
Kahoot
Warm up 🧠
About Python
Features
語法簡單 好上手(很口語化)
很多第三方函式庫
熱門 packages
熱門 packages (AI)
熱門 packages (Web)
執行速度 ?
執行速度
其實不快!
應該說是非常慢 🐢
熱門程度
https://youtu.be/GVmeP21x3iM
Summary of Python
Pros
Cons
無論如何
每個語言都有優缺點和適用的場域
Python 仍是目前的主流語言 ✅
Python syntax
comment
comment
在寫任何一行 code 之前
先學會要怎麼寫註解!
不然寫完過三天就看不懂了single line comment
multiple line comment
stdout
Output Example
( 預設就會換行 )
Print with different data type
Print multiple variables
,
分開要輸出的東西( 預設會用空白隔開 )
Customize end char
end="你想要的結尾"
Customize separator
sep="你想要的結尾"
,
分隔Lab
Zerojudge d483
stdin
input()
Input example
Input with prompt
Lab : on your own
三角形面積計算機
width
height
Example Input:
Example Output:
Lab : Zerojudge a001
a001. 哈囉
variables & data types & operator
variables
variables:變數
data type:資料型態
variables 變數
variables Naming 變數命名
+
-
*
/
%
&
連接( 底線_
可以)while
if
else
…Correct Naming Example
Mistake Naming Example
Naming Style
hasCar
coolBlueBigCar
has_car
cool_blue_big_car
readable variables naming
盡量把變數命名的有意義!
Bad example
Good example
variable naming for configuration
在專案中用於 設定相關 的變數
大多會命名成 底線搭配全大寫
Lab
data type
data type 資料型態
Python 基礎的資料型態:
str
int
float
bool
byte
NoneType
check data type
如何確認資料型態?
check data type
如何確認資料型態
type casting
如何把「字串」轉乘「整數」呢?
或是
如何把「整數」轉乘「浮點數」呢?
type casting Examples
operator
operator 運算子
跟一般數學一樣,Python 也可以
+
-
*
/
operator example
operator example
divide operator
除法的陷阱
次方
現在
a
,n
兩個變數,要計算a
的n
次方operator of power
不是
^
是**
兩個乘號mod operator
取餘數
math :
programming :
Example :
operator between different type
不同型態之前可以運算嗎?
Example
X = X + 1
X = X + 1
Lab : on your own
輸入
a
b
兩個變數,並輸出以下結果Example output:
Lab : Zerojudge d827
d827. 買鉛筆
Python is an interpreter language
Python 是一個直譯語言 (?
Compiled language
vs
Interpreter language
編譯語言
vs
直譯語言
編譯語言
compile 成 binary file (二進位檔)
直譯語言
(讀到的當下才轉成
0
跟1
)既然 Python 是直譯語言
Lab : on your own
來跟 Python Interpreter 玩一下