ECON 3209 · Week 2, Lecture 1 · Kerala Agricultural University
Autumn 2026
By the end of this lecture, you will be able to:
if, elif, and else to make economic decisions in codefor and while loops to process repeated calculationsbreak and continueA loan officer deciding whether to approve, reject, or review an application is using the same logic as an if/elif/else block.
if, elif, elseif checks the first conditionelif means “else if” and handles additional caseselse runs when no earlier condition is true: starts a code blockand when all conditions must be trueor when any one condition is enoughnot to reverse a conditionLoan approved if:
\[(\text{income} \geq 30000) \; \text{and} \; (\text{credit score} \geq 700) \; \text{and} \; (\text{default history} = \text{False})\]
True or Falseif statement depends on the combined resultfor Loopsfor loop repeats code over a sequencefor when you know what items you want to iterate overtotal = 0range() and Counting Loopsrange(5) gives 0, 1, 2, 3, 4range(2021, 2026) gives 2021 to 2025stop value is not includedrange() is ideal for fixed-number repetitionwhile Loopswhile loop continues as long as a condition remains truewhile loops are common in simulations and iterative finance problemsbreak and continuebreak exits the loop immediatelycontinue skips the rest of the current iteration: after if, for, or whilewhile loop with no progress toward stoppingx, y, and zDebugging tip: read your loop aloud — “for each district, do this calculation” — and then check whether the code matches that sentence.
A cooperative bank reviews annual loan recovery rates: 92, 88, 95, 76, 90.
for loop to print each rate.80, print Needs field visit.90.if/elif/else lets Python choose between alternativesfor loops repeat code across known sequenceswhile loops repeat until a condition becomes falsebreak stops a loop; continue skips one iterationECON 3209 — Kerala Agricultural University