Professional Documents
Culture Documents
Lec 1
Lec 1
Datatype in Python
In [3]: 1 x = 10
2 type(x)
Out[3]: int
In [4]: 1 y = 32.4
2 type(y)
Out[4]: float
In [5]: 1 z = 4+9j
2 type(z)
Out[5]: complex
1.2.1 Strings
Out[8]: str
Out[9]: str
In [13]: 1 x = """apple""" # triple quotes : docstring
2 type(x)
Out[13]: str
1.2.2 List
In [18]: 1 # list
2 x = ["apple", "orange","grapes"] # square bracets
3 type(x)
Out[18]: list
1.2.3 Tuple
Out[17]: tuple
1.2.4 Set
Out[21]: set
1.2.5 Dictionary
Out[23]: dict
1.2.6 Boolean
In [30]: 1 type(True)
Out[30]: bool
1.2.7 NoneType
In [32]: 1 type(None)
Out[32]: NoneType
Casting
<class 'str'>
<class 'int'>
<class 'float'>
In [42]: 1 print(x);print(type(x))
2 print(y);print(type(x))
3 print(z);print(type(x))
s1
<class 'str'>
2
<class 'str'>
3.0
<class 'str'>