forked from easyawslearn/Python-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython_math_module_example.py
More file actions
61 lines (43 loc) · 1.42 KB
/
Python_math_module_example.py
File metadata and controls
61 lines (43 loc) · 1.42 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
#Python | math() function
import math
# Python code to demonstrate the working of
#demonstrate of math module to pi value
print ("The pi value is : ", end="")
print (math.pi)
#demonstrate of math module to math e value
print ("The math e value is : ", end="")
print (math.e)
#demonstrate of math module sin formula
print ("The sin(10) value is : ", end="")
print (math.sin(10))
#demonstrate of math module cos formula
print ("The cos(10) value is : ", end="")
print (math.cos(10))
#demonstrate of math module log10 formula
print ("The log10(10) value is : ", end="")
print (math.log10(10))
#demonstrate of math module for factorial function
print ("The factorial value of 5 is : ", end="")
print (math.factorial(5))
#demonstrate of math module for square root function
print ("The square root value of 9 is : ", end="")
print (math.sqrt(9))
# Python code to demonstrate the working of
# ceil() and floor()
a = 2.3
# returning the ceil of 2.3
print ("The ceil of 2.3 is : ", end="")
print (math.ceil(a))
# returning the floor of 2.3
print ("The floor of 2.3 is : ", end="")
print (math.floor(a))
# Python code to demonstrate the working of
# fabs() and factorial()
a = -10
b= 5
# returning the absolute value.
print ("The absolute value of -10 is : ", end="")
print (math.fabs(a))
# returning the factorial of 5
print ("The factorial of 5 is : ", end="")
print (math.factorial(b))