-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumbers.py
More file actions
38 lines (32 loc) · 894 Bytes
/
numbers.py
File metadata and controls
38 lines (32 loc) · 894 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
35
36
37
38
from decimal import Decimal as d
from fractions import Fraction as f
import math
def main():
# basic numeric data types in python
print(type(6))
print(type(6.5))
print(type(6+7j))
num=6+7j
print(isinstance(num, complex))
#operations using binary, octal, hexadecimal
print(0b100010010)
print(0b100010010+0o15)
print(0b100010010+0xFB)
#python casting
print(int(63.7))
print(float(63))
print(float('63.26'))
#using Decimal module to get more precise values
print(0.1)
print(d(0.1))
print(d(202.5624) *d(1235.984316))
#using fractions module
print(f('1.1')+f(12,10))
print(f(-3,5)>0)
#using math module
print(math.pi)
print(math.cos(math.pi))
print(math.factorial(26))
print(math.cos(math.pi)+math.sin(math.pi))
if __name__ == '__main__':
main()