1.1.7 Data Types
1.1.7 Data Types
2
Setting Data Type in Python
In Python, the data type is set when you assign a value to a variable:
3
Setting Data Type in Python
Example Data Type
x = {"name" : "John", "age" : 36} dict
x = {"apple", "banana", "cherry"} set
x = frozenset({"apple", "banana", "cherry"}) frozenset
x = True bool
x = b"Hello" bytes
x = bytearray(5) bytearray
x = memoryview(bytes(5)) memoryview
4
Setting Specific Data Type in Python
5
Setting Specific Data Type in Python
6
Python Basics
Operation Output
● 2+3 5
● 9–8 1
● 4*6 24
● 8/4 2.0 (Why)
● 5/2 2.5
● 5 // 2 2 (integer or floor division )
● 8 + 9 -10 7 (multiple operation)
● 8+2*3 14
● (8 + 2) * 3 30
● 2 ** 3 8 (Power of)
● 10 % 3 1 (remainder) 7