-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatatypes.py
More file actions
102 lines (79 loc) · 1.82 KB
/
Copy pathdatatypes.py
File metadata and controls
102 lines (79 loc) · 1.82 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
#datatypes
num=5
type(num)
#here the 5 value we are assigning to the variable called num
#output:int [type which tells the datatype of that assigned value]
num=23569762555076356367287
type(num)
#output:int
/*In Python 3, the distinction between int and long no longer exists. All integers are treated as int and can grow to arbitrary size. Therefore,
there's no need to explicitly check for long*/
num=5.3
type(num)
#output:float
num=2+5j
type(num)
#output:complex
#to get above complex value seperately with real and imaginary part
num.real
#output:2.0
num.imag
#output:5.0
num=-5467.965
num
#output:-5467.965
num1=10
num2=2
print(num1+num2)
#output:12
print(num1-num2)
#output:8
print(num1*num2)
#output:20
print(num1/num2)
#output:5.0 [we got float type output here]
print(10/3)
#output:3.333333333333335 [output we get will be in decimal value not whole number]
/* if you want output in whole number use floor division*/
print(10//3)
#output:3
print(num1%num2)
#output:0
print(num1**num2)
#output:100 [we get 10**2 which is 10^2]
/*conversions*/
x="192"
type(x)
#output:str
#though the value is in x but the value is in double quotes so it will consider the type as string
int(x)
#ouput:192
x=int(x)
type(x)
#output:int
x=float(x)
print(x)
#output:192.0
x=complex(x)
print(x)
#output:(192+0j)
print(complex(2,6))
#output:2+6j
/* Functions */
x=-7.5
print(abs(x))
#output:7.5 [absolute value]
import math
x=20
print(math.exp(x))
#output:22026.465794806718[exp is the exponent value ]
math.e
#output:2.718281828459045 [in this e give constant value]
math.pi
#output:3.141592653589793
print(math.sqrt(6))
#output:2.449489742783178
max(1,34,65,378,36,2221)
#output:2221
min(1,33,4555,5677,322,0)
#output:0