Expressions and Statements in Python Class 11 CBSE Computer Science
Class 11 · Computer Science
Expressions and Statements in Python (CBSE Class 11 Computer Science)
Every Python program is made up of expressions and statements. An expression performs calculations and produces a value, while a statement is an instruction that tells Python to perform an action. Understanding the difference between these two concepts is essential for writing correct Python programs.
Learning Objectives
- Understand Expressions.
- Understand Statements.
- Identify Operands and Operators.
- Learn Expression Evaluation.
- Differentiate between Expressions and Statements.
What is an Expression?
An Expression is a combination of operands (values or variables) and operators that is evaluated to produce a single value.
Components of an Expression
Expression
│
├── Operands
└── Operators
Example Expressions
| Expression | Value |
|---|---|
| 5 + 3 | 8 |
| 20 / 4 | 5.0 |
| 10 % 3 | 1 |
| 2 ** 4 | 16 |
| 15 > 8 | True |
Example Program
a = 20
b = 5
result = a * b + 10
print(result)
Output
110
Dry Run Table
| Step | Statement | Variable Values | Output |
|---|---|---|---|
| 1 | a = 20 | a = 20 | - |
| 2 | b = 5 | a = 20, b = 5 | - |
| 3 | result = a * b + 10 | result = 110 | - |
| 4 | print(result) | - | 110 |
Operands and Operators
Every expression contains operands and operators.
25 + 15
25 → Operand
+ → Operator
15 → Operand
What is a Statement?
A Statement is a complete instruction that Python executes.
Examples of Statements
x = 10
print(x)
if x > 5:
print("Large")
for i in range(5):
print(i)
Each of the above is a Python statement.
Types of Statements
| Statement Type | Example |
|---|---|
| Assignment | x = 25 |
| Input | name = input() |
| Output | print(name) |
| Conditional | if marks >= 33: |
| Loop | for i in range(5): |
Expression vs Statement
| Expression | Statement |
|---|---|
| Produces a value. | Performs an action. |
| Can be part of a statement. | Executes independently. |
| Example: a + b | Example: print(a + b) |
Expression Evaluation
Python evaluates expressions according to operator precedence. The final result depends on the order in which operators are applied.
5 + 3 * 2
= 5 + 6
= 11
A detailed discussion on operator precedence is covered in the next article.
Think Like a Programmer
Identify whether each is an Expression or a Statement.
| Code | Answer |
|---|---|
| 25 + 15 | Expression |
| x = 25 | Statement |
| print(x) | Statement |
| x * y | Expression |
| 100 / 5 | Expression |
Output Prediction Challenge
x = 12
y = 8
print(x + y)
print(x * y)
print(x > y)
Click to View Answer
20
96
True
Real-Life Example
Suppose a teacher calculates the total marks of a student.
- Expression: English + Maths + Science
- Statement: Display the total marks on the report card.
Common Beginner Mistakes
- Thinking every statement is an expression.
- Confusing assignment with expressions.
- Ignoring operator precedence.
- Assuming
print()is an expression instead of a statement.
Memory Trick
- Expression → Produces a Value
- Statement → Performs an Action
Exam Tips
- Remember the difference between expressions and statements.
- Practice identifying expressions from Python code.
- Understand that expressions are evaluated to produce values.
- Know that statements perform actions.
CBSE Important Questions
2 Marks
- Differentiate between an expression and a statement.
- What are operands and operators?
3 Marks
- Explain expression evaluation with an example.
- Write two expressions and two statements in Python.
5 Marks
- Explain expressions and statements with suitable examples and a comparison table.
Practice Yourself
- Write five expressions and find their values.
- Write five Python statements.
- Identify expressions and statements from a given Python program.
- Create your own expression using arithmetic and relational operators.
- Write a program that uses both expressions and statements.
Frequently Asked Questions (FAQs)
1. What is an expression?
An expression is a combination of operands and operators that produces a value.
2. What is a statement?
A statement is a complete instruction executed by Python.
3. Can an expression exist without a statement?
Yes. An expression can be evaluated independently in Interactive Mode.
4. Can a statement contain an expression?
Yes. For example, x = 5 + 3 is a statement containing an expression.
5. Which produces a value: an expression or a statement?
An expression produces a value.
Summary
- An expression produces a value.
- A statement performs an action.
- Expressions consist of operands and operators.
- Statements include assignment, input, output, conditional, and looping statements.
- Understanding expressions and statements is essential before learning operator precedence, type conversion, and control flow.