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
Python if
資訊之芽 Python 語法班 2023/03/12
鄧人豪
課程大綱 Outline
課程回顧 Recap
輸出
變數
輸入
運算子
比較運算子 Comparison Operators
比較運算子
<
,>
: 小於, 大於<=
,>=
: 小於等於, 大於等於==
,!=
: 等於, 不等於範例
注意!!!
=
與==
不一樣喔=
用來 指定 變數的值==
用來 比較 是否相等=
與==
不一樣那這樣呢?
比較規則 Comparison Rule
==
與!=
例外)舉個例子
Questions?
邏輯運算子 Logical Operators
邏輯運算子
and
B: A 且 Bor
B: A 或 Bnot
A: 非 A真值表 Truth Table
範例
進階範例
Operator Precedence: not > and > or
Questions?
if-else 基本語法
情境
注意:冒號與縮排(後面說明)
這樣正確嗎?
解決辦法:使用 if-elif-else
條件句重點整理
再來一個範例
覺得混亂就畫流程圖看看吧~
Note:
https://drive.google.com/drive/folders/1eW1YUmnGgn1_kCZW23e04Pk2isBYubM5
Questions?
縮排 Indentation
錯誤範例
正確範例
區塊範圍
同樣的縮排空白數代表在同個區塊中
範例1:
VS
範例2:
VS
注意!區塊內不可以是空的喔
錯誤範例
快樂的練習時間 ( ̄▽ ̄)~*
neoj 3010 野豬騎士來囉
巢狀 Nested if
但拜託別這樣做 (。﹏。*)
請善用邏輯運算子
但如果條件很多怎麼辦?
請用
\
換行\
後必須直接換行,不可以有任何空白Questions?
又是快樂的練習時間 (๑•̀ㅂ•́)و✧
neoj 3011 三元排序
補充
稍長的程式碼
三元運算子 Ternary Operator
真值測試 Truth Value Testing
False
其他的都是 True
Truth Value Testing
範例
Questions?
寫作業囉 ✧(≖ ◡ ≖✿)
neoj 3401 超級貓貓星際漫遊-1
neoj 3402 超級貓貓星際漫遊-2
Thanks!