-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath module.py
More file actions
68 lines (46 loc) · 1.46 KB
/
Copy pathmath module.py
File metadata and controls
68 lines (46 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
57
58
59
60
61
62
63
64
65
66
67
68
#----Math---- calls, square root , ceil, floor, pi, triangles(sin,cos,..), power, factorial, exponential
#------calls(cals)---------
import math
def cals():
print("hello"); #calls the value (hello)
cals()
import math
def cals(a,b):
print(a+b); # a+b=5
cals(3,2) #calls the values(3,2)
#------square root (sqrt)------------
import math
print(math.sqrt(49)) #square root of (7) is 49
print(math.sqrt(36)) #square root of (6) is 36
#------ceil---> up to the nearest integer
import math
print(math.ceil(4.4)) # 4.4 up to the nearest value is 5
print(math.ceil(3.2)) # 3.2 up to the nearest value is 4
#-----floor---> down to the nearest integer
import math
print(math.floor(4.4)) # 4.4 down to the nearest value is 4
print(math.floor(3.2)) # 3.2 down to the nearest value is 3
#-----pi------>
import math
print(math.pi) # pi = 3.14
#for example - Area of circle
import math
radius=5
area= math.pi*radius*radius
print(area) # area = 78.539
#----Triangles-------
import math
print(math.sin(0)) # sin(0)=0
print(math.cos(0)) # cos(0)=1
#----power----
import math
print(math.pow(3, 2)) # 3 power 2 is (9) like 3*3=9
#or
print(3**2) # (9)
#----factorial----
import math
print(math.factorial(3)) # 3!=3*2*1 = (6)
#----Exponential-----
import math
print(math.exp(1)) # e^1 = 2.7182
print(math.exp(2)) # e^2 = 7.3890