-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMath_Basic_Ops.py
More file actions
46 lines (27 loc) · 1.01 KB
/
Math_Basic_Ops.py
File metadata and controls
46 lines (27 loc) · 1.01 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
# Round numbers # to two Decimal places
print( round(3.1415926, 2) ) ;print()
# Absolute Value of a number
print( abs(-5) ) ; print()
# Convert numbers from decimal to different formats
# -------------------------------------------------
# Binary
print( bin(20) ) ; print()
# Octal Base 8
print( oct(20) ) ; print()
# Hexidecimal Base 16
print( hex(20) ) ; print()
# Complex The first two numbers of the output indicate the new base
print( complex(2,3) ) ; print()
# output: (2+3j)
# Math Library
# -------------------------------------------------
import math
# square root
print( math.sqrt(9) ) ; print()
# PI
PI = math.pi
print( PI ) ; print()
# sin
print( math.sin(PI/2) ) ; print()
# Log
print( math.log(100, 10) ) ; print()