-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSummary_of_datatype.txt
187 lines (103 loc) · 2.17 KB
/
Summary_of_datatype.txt
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
DATATYPE DESCRIPTION IS IMMUTABLE? EXAMPLE
Int
We can use to Represent the whole / integral
Numbers.
Immutable >>> a=10
>>> type(a)
<class ‘int’>
Float
We can use to represent
Decimal / Floating
Point numbers.
Immutable
>>> b=10.5
>>> type(b)
< class ‘float’>
Complex
We can use to represent
The complex numbers.
Immutable
>>> c=10+5j
>>> type(c)
Bool
We can use to represent the logical values ( Only allowed values are True and False )
Immutable
>>> flag = True
>>> flag = Flase
>>> type (flag)
<class’bool’>
Str
To represent sequence
Of Characters.
Immutable >>> s=’shivansh’
>>> type(s)
<class ‘str’>
>>>s=”Shivansh”
>>> s=’’’not fikarr ,No fear. When Shivansh Gupta
Is here ‘’’
>>>type(s)
<class ‘str’>
BytesTo represent a sequence of BYTES
Values from 0-255
Immutable>>> list = [1,2,3,4]
>>> ba = bytearray(list)
>>> type(ba)
<class ‘bytearray’>
BytearrayTo represent a sequence of BYTE
Value from 0-255
Mutable >>> list=[10,20,30,40]
>>>ba=bytearray(list)
>>> type(ba)
<class ‘bytearray’>
Range
To represent a range of
Values
Immutable
>>> r=range(10)
>>> r1 = range(0,10)
>>> r2 = range(0,10,2)
list
To represent an ordered collection of
Objects.
Mutable>>> l=[10,20,30,40,50,60]
>>> type(l)
<class ‘list’>
Tuple
To represent an ordered collections of objects.
Immutable>>> t=(1,2,3,4,5)
>>> type(t)
<class ‘tuple’>
Set
To represents an unordered collection
of UNIQUE Objects.
Mutable>>> s=(10,20,30,40,50)
>>> type(s)
<class ’set’>
Frozement
To represent an unordered collection
Of unique Objects.
Immutable>>> s=( 11,2,3,’Shiva’,100,’Gupta’)
>>> fs=frozenset(s)
>>> type(fs)
<class ‘ frozensets’>
DictTo represents a group of key values
Pairs.
Mutable>>>
d=(101:’shiva’,102:’gupta’,103:’ramu’)
>>> type(d)
<class ‘dict’>