- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path006_mathFunctions.py
More file actions
Latest commit
56 lines (49 loc) · 1.46 KB
/
Copy path006_mathFunctions.py
File metadata and controls
56 lines (49 loc) · 1.46 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
importmath
importrandom
print("5 + 2 = ", 5+2)
print("5 - 2 = ", 5-2)
print("5 * 2 = ", 5*2)
print("5 / 2 = ", 5/2)
print("5 // 2 = ", 5//2)
print("5 % 2 = ", 5%2)
print("5 ** 2 = ", 5**2)
# shorcut equation
# add 1
i=2
i+=1
print("i = ", i)
# Math Functions
print("abs(-1) ", abs(-1))
print("max(5, 4) ", max(5, 4))
print("min(5, 4) ", min(5, 4))
print("pow(2, 2) ", pow(2, 2))
print("ceil(4.5) ", math.ceil(4.5))
print("floor(4.5) ", math.floor(4.5))
print("round(4.5) ", round(4.5))
print("exp(1) ", math.exp(1)) # e**x
print("log(e) ", math.log(math.exp(1)))
print("log(100) ", math.log(100, 10)) # Base 10 Log
print("sqrt(100) ", math.sqrt(100))
print("sin(0) ", math.sin(0))
print("cos(0) ", math.cos(0))
print("tan(0) ", math.tan(0))
print("asin(0) ", math.asin(0))
print("acos(0) ", math.acos(0))
print("atan(0) ", math.atan(0))
print("sinh(0) ", math.sinh(0))
print("cosh(0) ", math.cosh(0))
print("tanh(0) ", math.tanh(0))
print("asinh(0) ", math.asinh(0))
print("acosh(pi) ", math.acosh(math.pi))
print("atanh(0) ", math.atanh(0))
print("hypot(0) ", math.hypot(10, 10)) # sqrt(x*x + y*y)
print("radians(0) ", math.radians(0))
print("degrees(pi) ", math.degrees(math.pi))
# Random
print("Random Integer: ", random.randint(1, 101))
# Infinity
print("Infinity: ", math.inf)
# Is infinity greater than 0?
print("Is infinity greater than 0? ", math.inf>0)
# Subtract infinity with infinity which resulted in nan
print("infinity - Infinity: ", math.inf-math.inf)