Page 467 - ComputerScience_Class_11
P. 467
iNtroductioN to PytHoN
oPeratorS aNd exPreSSioNS
Learning Objectives
12.1 Forms of Operators 12.2 Types of Operator
12.3 Expression 12.4 Statement
12.5 Operator Precedence 12.6 Type Conversion
In the previous chapter, you learned about data types and how variables can store different kinds of values, such as
numbers, text and logical values. But storing data is only the first step to make programs useful, we need to perform
operations on these values. Just like in mathematics we use symbols such as +, -, * and / to carry out calculations, in
Python we use operators to manipulate data.
Understanding operators is important because they form the building blocks of Python programs, enabling us to
calculate, make decisions and manipulate data efficiently. This chapter will explore all the different types of Python
operators with examples to help you write effective programs.
12.1 FORMS OF OPERATORS
An operator is a special symbol or keyword in Python that tells the computer to perform a specific operation
on one or more values, called operands. Operators are used to carry out tasks such as mathematical calculations,
comparisons, logical decisions, assignments and data manipulation. They are the basic building blocks for writing
Python programs.
For example,
a = 10
b = 5
c = a + b
print("The sum of a and b: ", c)
In this example, + is the operator that adds the operands a and b. Here, a = 10 and b = 5, so Python calculates
10 + 5 and stores the result 15 in c. Printing c displays:
The sum of a and b: 15. This example demonstrates how operators work with operands to perform calculations
in Python.
Operators and Expressions 465

