-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathModule-Part1.py
More file actions
34 lines (28 loc) · 902 Bytes
/
Copy pathMathModule-Part1.py
File metadata and controls
34 lines (28 loc) · 902 Bytes
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
"""
Farhan Javed
farhan.javed47@gmail.com
12/15/2019
Basic Math functionality in python 3 - Part 1
https://docs.python.org/3/library/math.html
"""
import math
def main():
# constants in the math module
print(math.pi) # Pi constant
print(math.e) # The Euler's constant
print(math.nan) # Not a number
print(math.inf) # +ive infinity
print(-math.inf) # -ive infinity
# basic trigonometry
# trigonometric functions take angles in randians
angle_in_degrees = 90
angle_in_radians = math.radians(angle_in_degrees)
print(math.sin(angle_in_radians))
print(math.cos(angle_in_radians))
print(math.tan(angle_in_radians))
# Ceiling and floor functions work on the closest integer
my_age = 24.6
my_salary = 45.8
print(f'My age is {math.floor(my_age)}')
print(f'My salary is {math.ceil(my_salary)}')
if __name__ == '__main__': main()