Module 2
Operators and Control Flow
// Lessons
6
// Quiz questions
90
// Reading time
90 min
// Exam length
15 Q
// Coding exercises
10
- 1Operators & ExpressionsPerform calculations, evaluate comparisons, and check identity or membership across expressions. 15 min 15 questions
- 2Operator Precedence & EvaluationMaster PEMDAS execution order, short-circuit boolean logic, and truthy versus falsy evaluations. 15 min 15 questions
- 3Interactive Input & OutputCapture user terminal inputs, format dynamic strings with f-strings, and handle stream I/O. 15 min 15 questions
- 4Conditional Branching (if / elif / else)Control decision branches, chain relational comparisons, and evaluate multi-condition logic. 15 min 15 questions
- 5Definite Iteration & for LoopsTraverse sequences and collections, generate indices with range(), and accumulate running values. 15 min 15 questions
- 6Indefinite Loops & Loop ControlManage condition-driven repetition with while loops, short-circuit with break, and advance with continue. 15 min 15 questions
Coding practice: write it yourself
Real Python, real checks: write your answer, press Run checks, and keep going until it passes. (4 exercises)
Coding practice needs an account. Sign in or create a free ID to run these exercises.
Lab 1: Even or odd?
number = 8. Print EVEN if it divides by 2 with no remainder, otherwise ODD.
Coding Practice is Locked
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.
Lab 2: Times table rows
Using a for loop over range(1, 4), print:
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15
Coding Practice is Locked
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.
Lab 3: Pass mark check
Bangladesh's pass mark is 33. For marks = 38, print PASS when marks is at least 33, else FAIL.
Coding Practice is Locked
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.
Lab 4: Exam countdown
Print a countdown from 3 down to 1, one number per line, using a while loop.
Coding Practice is Locked
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.
References & Further Reading
Related entries from PyLabs's own reference library.
- bool() (Convert a value to True or False.)
- range() (Make a sequence of evenly spaced integers.)
- enumerate() (Pair each item with a counter.)