-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathch3_10.py
43 lines (41 loc) · 1.17 KB
/
ch3_10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# ch3_10.py
x = -10
print("以下輸出abs( )函數的應用")
print(x) # 輸出x變數
print(abs(x)) # 輸出abs(x)
print("-----------------------")
x = 5
y = 3
print("以下輸出pow( )函數的應用")
print(pow(x, y)) # 輸出pow(x,y)
print("-----------------------")
x = 47.5
print("以下輸出round(x)函數的應用")
print(x) # 輸出x變數
print(round(x)) # 輸出round(x)
print("-----------------------")
x = 48.5
print(x) # 輸出x變數
print(round(x)) # 輸出round(x)
print("-----------------------")
x = 49.5
print(x) # 輸出x變數
print(round(x)) # 輸出round(x)
print("-----------------------")
print("以下輸出round(x,n)函數的應用")
x = 2.15
print(x) # 輸出x變數
print(round(x,1)) # 輸出round(x,1)
print("-----------------------")
x = 2.25
print(x) # 輸出x變數
print(round(x,1)) # 輸出round(x,1)
print("-----------------------")
x = 2.151
print(x) # 輸出x變數
print(round(x,1)) # 輸出round(x,1)
print("-----------------------")
x = 2.251
print(x) # 輸出x變數
print(round(x,1)) # 輸出round(x,1)
print("-----------------------")