---
# System prepended metadata

title: python複習
tags: [教學簡報]

---

---
title : python複習
tags : 教學簡報
---

# python複習小時間

---

# 基本運算子小複習

---
```
+ 加法
- 減法
* 乘法
/ 除法
// 除法取整數
%  取餘數
** 平方
a <= b #a小於等於b
a >= b #a大於等於b
a == b #a等於b，不要和a = b搞混
a == b and b == c #a等於b而且b等於c
a == b or b == c #a等於b或b等於c
```

---

# 確認資料型態

---
type()

```python
name = "Kevin"
print(type(name))
```
output
```
<class 'str'>

```

---


# 迴圈(loop)

---
1. for
2. while
3. break and continue
---
# for 用法:

```python
for x in range(1, 11, 2):
    print(x)
```

---



# while 用法: 
```python
name = input("輸入你的名字:")

while name == "":
    print("你沒有輸入你的名字")
    name = input("輸入你的名字:")

print(f"Hello {name}")

```

---

# break and continue 用法:
 顧名思義就是
 break(跳出)
 continue(繼續)

---

continue
```python
for x in range(1, 20, 1):
    if  x == 10:
        continue
    else:
        print(x)
```

---

break
```python
for x in range(1, 21, 1)
    if x == 13:
        break
    else:
        print(x)
```
        
---


# if 用法:
如果...，就...
```python!
grade = int(input(輸入你的成績:))
if grade > 60:
    print("及格")
elif grade < 60:
    print("你被當了")
```

---

# 布林(bool)

---

通常放進 if 內一同使用
```python!
x= true
y= false
```

---

# 函式(def )

---

```python!
def bababa():
    print('lalala')
bababa()    # 執行函式，印出 lalala
```

---

# import 導入函式庫、模組

可以是已經寫好的程式或內建的
```python!
import random#導入內建隨機樹涵式庫

import statistics

```
---
