-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.py
More file actions
142 lines (108 loc) · 2.56 KB
/
Copy pathmath.py
File metadata and controls
142 lines (108 loc) · 2.56 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#EX6.1-QUEZON, ANGEL SIERRA C.
# PYTHON PROGRAMMING ACTIVITY
# EXPLORING THE MATH MODULE
# IMPORT THE MATH MODULE
import math
print('THIS IS A CHANGE')
# PRINTS THE CONSTANTS pi and Euler's Number
print("")
print("-----Constants of pi and Euler's Number-----")
print("")
e = math.e
pi = math.pi
print("Value of pi = ", pi)
print("Value of e = ", e)
#-----------------------
print("")
#----------------------
# PRINTS the SQUARE ROOT OF A NUMBER
print("-----Square root of a Number-----")
print("")
print("x = 12345")
# CALCULATES SQUARE ROOT BY MATH MODULE
x = 12345
SQRT = math.sqrt(x)
print("SQUARE ROOT OF x =", SQRT)
#---------------
print("")
#---------------
# RETURNS THE FACTORIAL OF A NUMBER
print("-----Factorial of a number-----")
print("")
x = 10
print("x = 10")
# CALCULATES THE FACTORIAL OF A NUMBER
Fact = math.factorial(x)
print("Factorial of x =", Fact)
#----------
print("")
#-----------
# RETURNS THE POWER OF A NUMBER
print("-----Power of a number-----")
print("")
base = 10
exponent = 10
print("base =", base)
print("exponent = ", exponent)
# Calculates the power of a number
POWER = math.pow(base, exponent)
print("The power of", base, "rasied to", exponent, "is", POWER)
# ---------------
print("")
# --------------
# Truncates a number
print("-----Truncate of a number-----")
print("")
print("x = 1234.5678")
x = 1234.5678
trunc = math.trunc(x)
print("Truncate of", x, "is", trunc)
#------------
print("")
#-----------
# RETURNS THE LOGARITHM OF A NUMBER
print("-----Logarithm of a number-----")
print("")
print("x = 123")
x = 123
# CALCULATES THE LOGARITHM OF A NUMBER
log = math.log(x)
print("The Logarithm of", x, "is", log)
#--------------
print("")
#--------------
# RETURNS THE TRIGONOMETRIC CALCULATIONS
print("-----Trigonometric Functions-----")
print("")
print("angle given: 45 degrees")
angle = 45
# CALCULATE SIN, COS, TAN
sin = math.sin(angle)
cos = math.cos(angle)
tan = math.tan(angle)
print("Sine Function = ", sin)
print("Cosine Function = ", cos)
print("Tangent Function = ", tan)
#------------
print("")
#-----------
# ANGLE IN DEGREES TO RADIANS
print("-----Degree to Radians Conversion-----")
print("")
print("angle = 45 degrees")
angle = 45
Rad = math.radians(angle)
print("ANGLE_ DEGREES = ", angle)
print("ANGLE_RADIANS = ", Rad)
#----------------
print("")
#--------------=
# ANGLE IN RADIANS TO DEGREES
print("-----Radians to Degrees-----")
print("")
rad = 0.785398
print("Angle in Radians = ", rad)
# CALCULATES the conversion radians - degrees
deg = math.degrees(rad)
print("ANGLE_RADIANS = ", rad)
print("ANGLE_DEGREES = ", deg)