Python Operators, Expressions and Operator Precedence | Complete Notes | CBSE Class 11 Informatics Practices (2026–27)
Class 11 · Informatics Practices
Python Operators, Expressions and Operator Precedence
Python allows programmers to perform calculations, compare values, make decisions, and manipulate data using operators. When operators and operands are combined, they form an expression. Understanding operators and their precedence helps in writing correct and efficient Python programs.
What is an Operator?
An operator is a symbol that performs a specific operation on one or more operands (values or variables).
Example
```python a = 10 b = 5 c = a + b print(c) ``` Output ```text 15 ```Here, + is an operator, while a and b are operands.
Types of Operators in Python
| Operator Type | Purpose | Examples |
|---|---|---|
| Arithmetic | Mathematical calculations | +, -, *, /, %, //, ** |
| Relational (Comparison) | Compare values | ==, !=, >, <, >=, <= |
| Logical | Combine conditions | and, or, not |
| Assignment | Assign values | =, +=, -=, *= |
| Membership | Check membership | in, not in |
| Identity | Compare object identity | is, is not |
Arithmetic Operators
| Operator | Description | Example | Result |
|---|---|---|---|
| + | Addition | 8 + 2 | 10 |
| - | Subtraction | 8 - 2 | 6 |
| * | Multiplication | 8 * 2 | 16 |
| / | Division | 8 / 2 | 4.0 |
| // | Floor Division | 9 // 2 | 4 |
| % | Modulus | 9 % 2 | 1 |
| ** | Exponentiation | 2 ** 3 | 8 |
Program
```python a = 12 b = 5 print("Addition =", a + b) print("Subtraction =", a - b) print("Multiplication =", a * b) print("Division =", a / b) print("Floor Division =", a // b) print("Remainder =", a % b) print("Power =", a ** b) ```Relational Operators
| Operator | Description |
|---|---|
| == | Equal to |
| != | Not equal to |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal to |
| <= | Less than or equal to |
Logical Operators
| Operator | Meaning |
|---|---|
| and | True if both conditions are True |
| or | True if at least one condition is True |
| not | Reverses the logical result |
Assignment Operators
| Operator | Equivalent To |
|---|---|
| = | x = 5 |
| += | x = x + 5 |
| -= | x = x - 5 |
| *= | x = x * 5 |
| /= | x = x / 5 |
Membership Operators
Membership operators check whether a value exists in a sequence such as a string or list.
```python name = "Python" print("P" in name) print("Z" in name) ```Identity Operators
Identity operators compare whether two variables refer to the same object.
```python a = [1,2] b = a print(a is b) print(a is not b) ```Expressions
An expression is a combination of operands, variables, constants, and operators that produces a value.
Examples
```python 10 + 5 a * b (x + y) / 2 ```Expression Evaluation
Expression evaluation is the process in which Python calculates the final value of an expression according to operator precedence and associativity.
Example
```python result = 10 + 5 * 2 print(result) ``` Output ```text 20 ```Multiplication is performed before addition.
Operator Precedence
| Precedence (High → Low) | Operators |
|---|---|
| 1 | () |
| 2 | ** |
| 3 | *, /, //, % |
| 4 | +, - |
| 5 | <, <=, >, >=, ==, != |
| 6 | not |
| 7 | and |
| 8 | or |
Examples of Operator Precedence
```python print(5 + 3 * 2) print((5 + 3) * 2) print(20 / 5 + 2) print(10 > 5 and 8 < 4) ``` Output ```text 11 16 6.0 False ```Real-Life Examples
| Situation | Operator Used |
|---|---|
| Calculate percentage | Arithmetic |
| Compare marks | Relational |
| Check age eligibility | Logical |
| Search an item in a list | Membership |
| Update account balance | Assignment |
Common Errors
| Mistake | Correct Concept |
|---|---|
| Using = instead of == for comparison. | == is used to compare values. |
| Ignoring operator precedence. | Use parentheses when needed. |
| Using / expecting integer output. | / always returns a float. |
| Confusing is with ==. | is checks identity, == checks value. |
Quick Revision
| Concept | Remember |
|---|---|
| Operator | Performs an operation |
| Expression | Combination of operands and operators |
| Evaluation | Produces the final result |
| Highest Precedence | () |
| Arithmetic | +, -, *, /, //, %, ** |
CBSE Exam Tips
- Remember the precedence order of operators.
- Practice tracing expressions step by step.
- Differentiate between = and ==.
- Know the purpose of each operator category.
- Use parentheses to improve readability.
Summary
Operators are symbols that perform operations on data, while expressions combine operators and operands to produce results. Python supports arithmetic, relational, logical, assignment, membership, and identity operators. Understanding operator precedence and expression evaluation helps programmers write accurate, efficient, and error-free programs.