Page 81 - Information_Practice_Fliipbook_Class11
P. 81
4 DATA TYPES AND
OPERATORS
Chapter Outline
4.1 Data Types 4.2 Mutable and Immutable Data Types
4.3 Visualising Execution of Python Code 4.4 Operators
4.5 Expressions 4.6 Precedence of Operators in Python
4.7 Type conversion 4.8 Types of Errors
Introduction
In the last chapter, we talked about Python's character set, tokens, variables, and input-output statements. A program
usually takes some data, does processing on it, and gives the user the results in the form they want. Depending on the
data type and the problem's nature, the input data must go through a number of operations before the user can get
useful results. In this chapter, we will discuss various types of data and the associated operations.
4.1 Data Types
A data type refers to a type of data and the operations that can be performed on the objects of that type. For instance,
the types int, float, and str correspond to integer, floating point, and string data. For example, 23, 12.75, and
'Hello World' are values of types int, float, and str, respectively. A data type in Python is also called a class.
Thus, instead of saying types int, float, and str, we can also say classes int, float, and str, respectively.
Thus, we would say that 23, 12.75, and 'Hello World' are objects of (or instances of) the classes int,
float, and str, respectively. Python allows different operations to be performed on different data types. We have
already seen examples of operations associated with the above-mentioned data types. Fig 4.1 shows some important
data types available in Python.
Python - Data Types
Numeric Dictionary Boolean Set Sequence Type
Integer Float Strings Tuple
Complex Number List
Fig 4.1: Data Types in Python
Data Types and Operators 67

