---
# System prepended metadata

title: 'W02: 2/21'

---

W02: 2/21
===

### [Python數學 (Python Math)](https://www.w3schools.com/python/python_math.asp)

#### 內置數學函數

| Method      | Description | Same as     |
| ----------- | ----------- | ----------- |
| `max(1, 2)` | 最大值      | `2`         |
| `min(1, 2)` | 最小值      | `1`         |
| `abs(x)`    | 絕對值      | `x` or `-x` |
| `pow(x, y)` | x的y次方    | `x**y`      |

### [Python數學模組 (Python math Module)](https://www.w3schools.com/python/module_math.asp)
使用Python數學模組前須先輸入"import math"
以下列出常用模組：

| Method              | Description       | Same as              |
| ------------------- | ----------------- | -------------------- |
| `math.factorial(x)` | x的階乘         | `x!`                 |
| `math.sqrt(x)`      | x的平方根       | `√(x)` or `x**(1/2)` |
| `math.sin(x)`       | x弧度的sin      | `sin x`              |
| `math.cos(x)`       | x弧度的cos      | `cos x`              |
| `math.tan(x)`       | x弧度的tan      | `tan x`              |
| `math.radians(x)`   | x°等值的弧度    | `x*π/180`            |
| `math.degrees(x)`   | x等值的角度     | `(x*180/π)°`         |
| `math.trunc(x.y)`   | (x.y)的整數部分 | `x`                  |
| `math.fabs(x)`      | x的絕對值       | `x` or `-x`          |

---

### 輸入與輸出
> `print()`：輸入
> `input()`：輸出

---

### 作業
作業放在[W03: 2/28](https://hackmd.io/V6xjFjVRQuy6ovryPYRjXw)