---
# System prepended metadata

title: 第二堂課

---

# 第二堂課
（蔣水晶，110251037)

**作業**
**第一題** ![](https://i.imgur.com/EXzaR3C.png)
程式碼：
import math 
a= math.sqrt (5)
b= 1/math.sqrt(3)
x=pow (a+b,3)
print(x)

得：D. 22

**第一題** ![](https://i.imgur.com/FX6dhqJ.png)
程式碼：
import math 
x= math.sqrt (125)+3*5-1+pow(2,2)
print (x)

得：B. 29

**第一題** ![](https://i.imgur.com/oxpYjF6.png)
程式碼：
import math 
x= 1/math.sqrt (5)
y= 4*pow(x,3)+2pow(x,2)-5*x+1
print (y)

得：-0.4782

**筆記**
1. The min() and max() functions can be used to find the lowest or highest value in an iterable
**例子：**
x = min(2, 3, 5，10)
y = max(2, 3, 5，10)
print(x)
print(y)
得：
2
10

2. The abs() function returns the absolute (positive) value of the specified number
**例子**
x = abs(-9)
print(x)
得：
9

3. The pow(x, y) function returns the value of x to the power of y (xy) 
**例子**
notes: “Return the value of 2 to the power of 3 (same as 2 * 2 * 2)”
x = pow(2, 3)
print(x)
得：
8

4. When you have imported the math module (匯入math), you can start using methods and constants of the module The example for sqrt, ceil, floor, and pi. 
* The math.sqrt() method for example, returns the square root of a number
**例子**
**import math**
x = math.sqrt(25)
print(x)
得： 
5

* The math.ceil() method rounds a number upwards to its nearest integer, and the math.floor() method rounds a number downwards to its nearest integer, and returns the result
**例子**
**import math**
import math (匯入math)
#把1.4當作参數，傳入到math.ceil()函數中
#把math.ceil（）運算的結果設定給x變數
x=math.ceil(1.4 )
y=math.floor(1.4)
print(x) 
print(y)
得：
2
1

* The math.pi constant, returns the value of PI (3.14...)
**例子**
**import math**
x = math.pi
print(x)
得：
3.141592653589793

