Computer Science

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.

Definition: An expression is a valid combination of variables, constants, operators, and function calls that produces a value.

Components of an Expression


Expression

│

├── Operands

└── Operators

Example Expressions

Expression Value
5 + 38
20 / 45.0
10 % 31
2 ** 416
15 > 8True

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.

Definition: A statement is a complete instruction that performs an action in a Python program.

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
Assignmentx = 25
Inputname = input()
Outputprint(name)
Conditionalif marks >= 33:
Loopfor 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 + 15Expression
x = 25Statement
print(x)Statement
x * yExpression
100 / 5Expression

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

  1. Differentiate between an expression and a statement.
  2. What are operands and operators?

3 Marks

  1. Explain expression evaluation with an example.
  2. Write two expressions and two statements in Python.

5 Marks

  1. Explain expressions and statements with suitable examples and a comparison table.

Practice Yourself

  1. Write five expressions and find their values.
  2. Write five Python statements.
  3. Identify expressions and statements from a given Python program.
  4. Create your own expression using arithmetic and relational operators.
  5. 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.