Grade 11 Information Technology · Lesson 6.4
Statements and Expressions
Unit 6: Fundamentals of Programming
An expression is a combination of values, variables and operators that Python evaluates to produce a single value, for example 3 + 4 * 2, price * qty, or age >= 18. A statement is a complete instruction that Python executes, such as an assignment total = price * qty, a print() call, or an if statement. Expressions are parts of statements: in total = price * qty, the expression price * qty is evaluated and the statement stores the result.
Key terms
- Expression
- combination of values and operators that evaluates to a value
- Statement
- complete instruction that Python executes
- Operator
- symbol that performs an operation, e.g. +
- Floor division (//)
- division keeping only the whole-number part
- Modulus (%)
- remainder after division
- Precedence
- order in which operators are evaluated
- Logical operators
- and, or, not
Key formulas
Summary
- Expressions produce values; statements perform actions.
- Arithmetic: + - * / // % **; / always gives a float.
- Precedence: brackets, **, then * / // %, then + -.
- Comparisons give True/False; and, or, not combine conditions.
In everyday life: A taxi fare program could use the expression base_fare + km * rate_per_km, and % to work out change in Birr notes.
Check yourself
- What is the difference between / and //?
- Evaluate 17 % 4.
- Evaluate 3 + 2 ** 2 * 2.
- When is x > 5 or x < 0 True?
Practice questions
1. What is the value of the Python expression 17 // 5?
Show answer
Answer: 3
// is floor division: 17 divided by 5 is 3.4, and the whole-number part is 3.
On WeLearn
The full lesson: reading notes, worked examples, class activities and the Unit 6 quiz
Study Statements and Expressions on WeLearnTeach Statements and Expressions with WeLearn
We will bring a demo to your school: a lesson on your interactive TV, a virtual lab and a classroom game, with your own teachers.
