Lesson 2 KeyPoints
int, float
int 為整數
float為 浮點數,帶有小數點的數, EX: 3.14
浮點數因為硬體限制,無法無限精確,EX: print(0.1 + 0.2) # gives 0.30000000000000004
支援科學記號,EX: print(3.9e9) ,輸出 3900000000.0
round()
四捨五入
import
引入額外的模組,EX: import math
引入額外的模組中的特定部分, EX: from math import ceil
math 數學模組 部分函數與內容
floor(x) — returns the largest integer less than or equal to x,
ceil(x) — returns the smallest integer greater than or equal to x,
sqrt(x) — returns the square root of x,
log(x) — returns the natural logarithm of x,
log(x,a) — returns the logarithm of x to base a,
pi is the mathematical constant pi = 3,1415926..
e — is the mathematical constant e = 2,71828..
sin(x) returns the sine of x in radians
cos(x) returns the cosine of x in radians
tan(x) returns the tangent function of x
asin(x) returns the arcsine of x in radians