Core Python
- Beginner level
- 12 weeks
- 4 modules
- 28 lessons
- 28 h 45 min of material
Overview
About this course
The student reads a problem, plans it, and writes a tested, well-structured Python program using functions, built-in data structures, files, classes and Git. This course is the gateway to every other Python category.
What you'll be able to do
- Plan before coding
Read a problem and plan the solution with an algorithm, flowchart or pseudocode before writing code.
- Write correct basic programs
Write correct programs using variables, data types, input/output, operators, conditions and loops.
- Solve problems with functions and data structures
Break programs into functions and solve LeetCode-easy problems with strings, lists, tuples, sets and dictionaries.
- Debug and test
Find bugs with a debugger, handle errors with exceptions, and prove code works with pytest tests.
- Work like a developer
Save and load data with files, CSV and JSON; organise code into modules; manage packages with pip and venv; and publish work on GitHub.
- Design with objects
Model real systems with classes and objects, and deliver an original, tested capstone project with a README and demo video.
How each lesson works
- WatchA short concept video
- ReadNotes worth keeping
- PredictGuess what code prints
- TryRun code in the compiler
- CheckA quick quiz
- BuildReal coding tasks
Introduction
Introduction: Why Python
Before writing a single line of code, meet the language: why Guido van Rossum built it, who keeps it alive today, how widely it is used, and exactly what you will be able to do by the end of this course.
-
30 min
Lesson 0.1Preview
The story of Python
Guido van Rossum, ABC and Amoeba at CWI; the Christmas 1989 hobby project; the name; first release in 1991; design choices (readability, indentation, extensibility); Python 2 to 3; from BDFL to Steering Council; the Zen of Python.
ShowHide the 5 steps
- Notes Why this lesson matters
-
Concept video
Story video: How Python was born
Hook · The problem: ABC · Amoeba · Python is born · Design choices · Growth and today
-
Notes
Notes: the story of Python
The problem Guido faced · The Christmas project · Design choices you will use every day · Timeline · The Zen of Python · Sources
- Try it Try it: the Zen of Python
-
Quick check
Quick check: the story of Python
4 questions
-
25 min
Lesson 0.2Preview
Who builds Python today
Open source and CPython; core developers; PEPs and the Steering Council; the Python Software Foundation; companies that fund and staff Python development.
ShowHide the 4 steps
- Notes Why this lesson matters
-
Concept video
Video: Who keeps Python running
Hook · Open source and CPython · How decisions are made · The PSF · Companies behind Python · Close
-
Notes
Notes: who builds Python
Python is open source · How decisions are made · Companies that support Python · Why companies invest · Sources
-
Quick check
Quick check: who builds Python
4 questions
-
25 min
Lesson 0.3Preview
Python in the world today
How popularity is measured (TIOBE, Stack Overflow survey, GitHub Octoverse, PYPL); where Python ranks in 2026; where Python is used; where it is not the best choice.
ShowHide the 4 steps
- Notes Why this lesson matters
-
Concept video
Video: Python in 2026, by the numbers
Hook · Four ways to measure · Where Python is used · Where it is not · Close
-
Notes
Notes: Python in the world today
There is no single "market share" · Where Python is used · Where Python is not the best choice · India and Python · Sources
-
Quick check
Quick check: Python in the world
4 questions
-
20 min
Lesson 0.4Preview
Your course roadmap and outcomes
The six course outcomes; the 12-module roadmap; how every lesson works; exams, capstone and certificate; AI policy; placement test; what comes after Core Python.
ShowHide the 4 steps
-
Concept video
Video: Your journey through Core Python
Welcome · Course outcomes · Roadmap · How lessons work · Study tips
-
Notes
Notes: course outcomes and roadmap
What you will be able to do · Roadmap · How every lesson works · Rules · Study tips · After Core Python
- Notes Set your goal
-
Quick check
Quick check: course rules
3 questions
-
Concept video
Video: Your journey through Core Python
Module 1
Getting Started: How Programs Run
By the end of this module you will run your own Python programs from the terminal, understand what happens inside the computer when a program runs, and plan a program before you write it.
-
60 min
Lesson 1.1Preview
What is programming?
Computer basics (CPU, memory, input and output) in 5 minutes; what a program is; what a programming language is; how this course works.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Your first program: just press Run
-
Concept video
Concept video: What is programming?
You just ran your first program · What a computer does · What a program is · Why programming languages · How every lesson works · Recap
-
Notes
Notes: computers, programs and languages
What a computer does · What is a program? · Why do we need programming languages? · How this course works · Common mistakes · Key words
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: Hello World!
- Try it Try it: run and change
- Arrange the code Arrange the code: ATM withdrawal
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Fix the welcome message
- Coding task Hello, World!
- Coding task Welcome banner
- Coding task Input, process, output of a calculator
-
Locked60 min
Lesson 1.2
Types of programming languages
Low-level vs high-level; generations of languages; compiled vs interpreted (and the bytecode middle path); static vs dynamic typing; programming paradigms; where Python fits.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: a name that changes its type
-
Concept video
Concept video: Types of programming languages
Hook · Levels and generations · Compiled vs interpreted · Static vs dynamic typing · Paradigms · Recap
-
Notes
Notes: types of programming languages
By level of abstraction · By generation · By how code is run · By typing · By paradigm · By application domain · Python in one line · Common mistakes
-
Predict the output
Predict the output
2 questions
- Try it Try it: dynamic typing in action
- Arrange the code Arrange: from low-level to high-level
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
C habits in Python
- Coding task Level of each language
- Coding task Compiled or interpreted
- Coding task Python profile card
Enroll to open this lesson -
Locked50 min
Lesson 1.3
Python versions and implementations
Version numbers (major.minor.micro); the yearly October release and 5-year support; Python 3.15 as the current version; why Python 2 code breaks; CPython, PyPy, MicroPython and others; choosing which version to install.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: ask Python its version
-
Concept video
Concept video: Python versions and implementations
Hook · Version numbers · Release and support · Python 2 vs 3 · Implementations · Which to install
-
Notes
Notes: versions and implementations
Reading a version number · Release and support cycle · Python 2 vs Python 3 · Implementations · Which version should you install? · Checking your version · Common mistakes · Sources
-
Predict the output
Predict the output
2 questions
- Try it Try it: which Python am I running?
- Arrange the code Arrange: Python's version history
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
2
- Coding task Parts of a version
- Coding task Implementations card
- Coding task Support timeline for 3.15
Enroll to open this lesson -
Locked75 min
Lesson 1.4
Setup, terminal and first program
BashaByte compiler; installing Python on Windows, macOS and Linux; checking the version; VS Code and the Python extension; terminal basics (pwd, cd, ls/dir, mkdir); the REPL; creating and running hello.py.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: your program, in the browser
-
Concept video
Concept video: setup, terminal and first program
Hook · Install Python · Check the version · VS Code · Terminal basics · The REPL · First file · Common errors
-
Notes
Notes: setup, terminal and first program
Install Python · Install VS Code · Terminal basics · The REPL: try code instantly · Your first file · Common errors and fixes · Sources
-
Predict the output
Predict what you will see
2 questions
- Try it Try it: your first file, on your own computer
- Arrange the code Arrange the terminal commands
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Mismatched quotes
- Coding task Setup check
- Coding task Terminal cheat sheet
- Coding task Show a REPL session
Enroll to open this lesson -
Locked75 min
Lesson 1.5
How Python runs your code
Source code to bytecode to the Python Virtual Machine; compiler vs interpreter vs assembler; .pyc files; print() with many values, sep and end; comments; reading SyntaxError, NameError and IndentationError.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: two lines, then a crash
-
Concept video
Concept video: how Python runs your code
Hook · Three stages · Compiler vs interpreter vs assembler · Proof with errors · print in depth · Comments · Reading a traceback
-
Notes
Notes: how Python runs your code
Three stages · Compiler vs interpreter vs assembler · Proof: two kinds of errors · print() in depth · Comments · Reading an error (traceback) · Common mistakes
-
Predict the output
Predict the output
2 questions
- Try it Try it: bytecode and print()
- Arrange the code Arrange the code: one-line receipt
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Missing comma
- Coding task Date with separator
- Coding task Loading message
- Coding task Address in one print
Enroll to open this lesson -
Locked75 min
Lesson 1.6
Thinking like a programmer
Algorithms and their properties; input, process, output; flowchart symbols; pseudocode; dry runs with trace tables; from problem statement to plan.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: the magic swap
-
Concept video
Concept video: thinking like a programmer
Hook · Problem to plan · Pseudocode · Flowcharts · Trace tables · Recap
-
Notes
Notes: thinking like a programmer
Five steps to solve any problem · Algorithm · Pseudocode · Flowcharts · Python can calculate · Dry run with a trace table · Common mistakes
-
Predict the output
Predict the output (dry run first)
2 questions
- Try it Try it: trace, then run
- Arrange the code Arrange the algorithm: GST bill
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: wrong order
Bill lines in the wrong order
- Coding task Area of a rectangle
- Coding task Average of three marks
- Coding task Kilometres to metres
Enroll to open this lesson
This module ends with a hands-on mini-project.
Module 2
Variables, Data Types and Input/Output
In this module you learn how Python remembers things and talks to people: variables as stickers on objects, the different kinds of data, taking input from a user, and printing neat, professional output.
-
Locked75 min
Lesson 2.1
Variables: stickers on objects
Why variables exist; the water-bottle and stickers story; variables as names that refer to objects; everything is an object; = as assignment; many names for one object and moving a name, checked with id(); naming rules, keywords and PEP 8 style.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: guess, then run
-
Concept video
Concept video: variables are stickers
The shop bill problem · The water-bottle story · Mapping to Python · Many stickers, one bottle · Moving a sticker · x = x + 1 · Naming rules and style · Recap
-
Notes
Notes: variables are stickers on objects
What is a variable? · The water-bottle story · The same idea in Python · The shop problem, solved · = does not mean "equal to" · Many stickers, one bottle: check it yourself · Moving a sticker · Naming rules (must follow) · Naming style (should follow) · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: watch the stickers with id()
- Arrange the code Arrange the code: bill with variables
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Wrong sticker name
- Coding task Price changed to 500
- Coding task Student profile sentence
- Coding task Batsman's score
Enroll to open this lesson -
Locked70 min
Lesson 2.2
Dynamic typing and the data type family
Static vs dynamic typing (the Blinkit example); type(); why Python is still strict about mixing types; the full family of built-in types by category; bool and None.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: Python knows every type
-
Concept video
Concept video: Python picks the container
Who picks the bottle? · Static typing · Dynamic typing · Strong typing · The data type family · bool and None · Phone number puzzle
-
Notes
Notes: dynamic typing and the data type family
The old way: you carry the right container · The Python way: Blinkit · type(): ask what container Python used · Flexible, but not careless · The data type family · bool: True and False · None: "nothing yet" · Choosing the right type for real data · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: ask Python about types
- Arrange the code Arrange the code: one of each type
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Text plus number
- Coding task What type is it?
- Coding task Student record with the right types
- Coding task Attendance counter with booleans
Enroll to open this lesson -
Locked75 min
Lesson 2.3
Integers and number systems
int and its unlimited size; underscores in big numbers; binary, octal and hexadecimal; bin(), oct(), hex() and int(x, base).
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: three strange 13s
-
Concept video
Concept video: integers and number systems
The orange button · int has no limit · Lakhs with underscores · The leading zero trap · Number systems by hand · bin, oct, hex and int · Where you will use them
-
Notes
Notes: integers and number systems
int: whole numbers of any size · Writing big numbers readably · The leading zero trap · Number systems · Converting by hand (aptitude favourite) · Let Python do it · Decode BashaByte's orange · Where you will meet these · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: numbers in different clothes
- Arrange the code Arrange: 13 to binary by hand
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Wrong base
- Coding task 25 in three systems
- Coding task Decode BashaByte orange
- Coding task Binary message
Enroll to open this lesson -
Locked60 min
Lesson 2.4
Floats and complex numbers
float; why 0.1 + 0.2 is not exactly 0.3; round(); scientific notation; complex numbers and where they are used.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: is Python's maths broken?
-
Concept video
Concept video: floats, rounding and complex numbers
0.1 + 0.2 surprise · What is a float · Why decimals are not exact · Rounding and banker's rounding · Money in real apps · Scientific notation · Complex numbers · Recap
-
Notes
Notes: floats and complex numbers
float: numbers with a decimal point · The 0.1 + 0.2 surprise · round(): neat numbers for display · Money in real apps · Scientific notation · complex numbers · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: floats under the microscope
- Arrange the code Arrange the code: a bill with GST
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: rupees and paise
Lost paise
- Coding task Petrol bill
- Coding task Numbers from science
- Coding task Complex number toolkit
Enroll to open this lesson -
Locked80 min
Lesson 2.5
Strings and taking input
str with single, double and triple quotes; escape characters; len(); ord() and chr(); input() always returns a string; converting with int() and float(); ValueError.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: 55 or 10?
-
Concept video
Concept video: strings and input
The 55 trap · Strings first look · input() · Converting types · Two values on one line · Recap
-
Notes
Notes: strings and taking input
Strings: first look · len() and indexing · Characters are numbers: ord() and chr() · input(): your program listens · Converting types (explicit conversion) · Implicit conversion · bool(): truthy and falsy · Two values on one line: split() · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: make your program listen
- Arrange the code Arrange the code: area calculator
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Age next year
- Coding task Welcome message
- Coding task Simple interest
- Coding task Two numbers on one line
Enroll to open this lesson -
Locked75 min
Lesson 2.6
Formatting output with f-strings
f-strings; format specs (.2f, width, alignment, thousands separator); printing receipts and tables; module mini-project.
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: a bill that looks professional
-
Concept video
Concept video: f-strings, the wedding card printer
The ugly bill · Wedding card template · Maths inside the blanks · Decimals, width, alignment · Commas and percentages · The debugging trick · Older styles · Recap
-
Notes
Notes: f-strings
The wedding card printer · Maths inside the blanks · Format specs: put a colon inside the blank · A bill that looks professional · Two honest notes · Senior tip: the debugging trick · Older styles you will see in old projects · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: design your own bill
- Arrange the code Arrange the code: restaurant bill
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the printer is switched off
Printer switched off
- Coding task Percentage calculator
- Coding task One aligned bill row
- Coding task Big amounts with commas
Enroll to open this lesson
This module ends with a hands-on mini-project.
Module 3
Operators and Expressions
Operators are the verbs of programming: add, compare, check, combine. In this module you learn every Python operator through real situations (sharing laddoos, checking eligibility, reading clocks), and you learn to predict the value of any expression before you run it.
-
Locked70 min
Lesson 3.1
Arithmetic operators
#ERROR!
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: 17 laddoos, three answers
-
Concept video
Concept video: the laddoo lesson
17 laddoos · The easy four · // and % · The negative surprise · Power · math module · Division by zero · Recap
-
Notes
Notes: arithmetic operators
The seven arithmetic operators · // and %: the laddoo operators · The negative surprise · Power: ** · math module basics · Division by zero · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: laddoos, clocks and buses
- Arrange the code Arrange the code: minutes to hours
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the missing half mark
The missing half mark
- Coding task Sharing laddoos
- Coding task Seconds to hours, minutes and seconds
- Coding task Booking buses
Enroll to open this lesson -
Locked70 min
Lesson 3.2
Comparison and logical operators
#ERROR!
ShowHide the 12 steps
- Notes Why this lesson matters
- Try it Run it first: Python answers yes or no
-
Concept video
Concept video: Python starts judging
Apps ask questions · Comparison operators · Chained comparisons · Strings and floats · and, or, not · The lazy watchman · or for defaults · Recap
-
Notes
Notes: comparison and logical operators
Comparison operators: asking questions · Chained comparisons · Comparing strings · Never compare floats with == · Logical operators: building rules · Short-circuit: the lazy watchman · Senior tip: or gives a default · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
- Try it Investigate: be the eligibility officer
- Arrange the code Arrange the code: scholarship check
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug
Arrow written backwards
- Coding task Can vote?
- Coding task Scholarship eligibility
- Coding task Leap year in one line
Enroll to open this lesson -
Locked55 min
Lesson 3.3
Assignment operators
#ERROR!
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: a scoreboard and a swap
-
Concept video
Concept video: the scorer's shortcut
You just ran it · The scorer's shortcut · Two traps · Multiple assignment and swap · a = b = 0 · The walrus · Recap
-
Notes
Notes: assignment operators
The scorer's shortcut · Stickers again · Two traps · Multiple assignment · The one-line swap · a = b = 0 · The walrus operator := · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: the scoreboard
- Try it Investigate: your UPI wallet
- Arrange the code Arrange the code: wallet updates
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the Java habit
Visitor counter
- Coding task UPI wallet
- Coding task Exchange seats
- Coding task Money that grows
Enroll to open this lesson -
Locked70 min
Lesson 3.4
Bitwise and shift operators
& | ^ ~ << >>; seeing numbers in binary; odd/even with & 1; power-of-two check; set, clear and toggle a bit; real uses such as permissions and flags.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: strange answers
-
Concept video
Concept video: thinking in switches
You just ran it · Rows of switches · AND, OR, XOR, NOT · Shifts · Real uses · Senior tip and recap
-
Notes
Notes: bitwise and shift operators
Numbers are rows of switches · The four switch operators · Shifts: sliding the switches · Real uses · Senior tip: brackets! · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: last bit
- Try it Investigate: play with switches
- Arrange the code Arrange the code: file permissions
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: wrong direction
Wrong direction
- Coding task Odd or even with bits
- Coding task Power of two in one line
- Coding task Bit toggler
Enroll to open this lesson -
Locked65 min
Lesson 3.5
Identity, membership and precedence
is vs == (stickers and id()); is None; in and not in with strings; operator precedence and associativity; ** works right to left; brackets for clarity.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: same water, different bottle
-
Concept video
Concept video: same water or same bottle?
Three puzzles · Same water or same bottle · in and not in · Python's BODMAS · Senior tip and recap
-
Notes
Notes: identity, membership and precedence
is vs ==: same water, or same bottle? · Use is only for None · in and not in: the attendance register · Precedence: Python's BODMAS · Three surprises · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: negative square
- Try it Investigate: bottles, registers and brackets
- Arrange the code Arrange the code: attendance register
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: brackets in the wrong place
Discount in the wrong place
- Coding task Vowel checker
- Coding task Brackets change everything
- Coding task Simple spam filter
Enroll to open this lesson -
Locked70 min
Lesson 3.6
Number problems
Last digit, digit sum and reverse of a 3-digit number with // and %; simple and compound interest; nth term of AP and GP; temperature conversion.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: taking a number apart
-
Concept video
Concept video: number magic for placements
You just ran it · Taking digits apart · Palindrome and Armstrong · The Gauss story · Real formulas · Senior tip and recap
-
Notes
Notes: number problems
Taking a number apart · Digit sum and reverse · Two placement classics · Sum of 1 to n: the Gauss trick · Real formulas · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: digit sum
- Try it Investigate: your number lab
- Arrange the code Arrange the code: reverse a number
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: a cold day in Hyderabad?
Boiling point
- Coding task Digit sum and reverse
- Coding task Interest calculator
- Coding task Auto fare
Enroll to open this lesson
This module ends with a hands-on mini-project.
Module 4
Control Flow: Making Decisions
Until now, Python ran every line, top to bottom, every time. In this module your programs start making decisions: run this block only if a condition is true, choose between two paths, pick one of many options. You'll build real decision programs like grade calculators, electricity bills and ATM menus.
-
Locked65 min
Lesson 4.1
The if statement and indentation
The if statement; conditions and the colon; indented blocks; what happens when the condition is False; truthy conditions; pass; IndentationError and TabError.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: a weather advisor
-
Concept video
Concept video: Python learns to decide
What if it's 25? · The if statement · Indentation: the tiffin box · Three common errors · Truthy conditions and pass · Recap
-
Notes
Notes: the if statement
The shape of an if · True runs the block, False skips it · Indentation: the tiffin box · Any truthy value works as a condition · pass: an empty box placeholder · Three errors every beginner meets · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: the weather advisor
- Try it Investigate: be the weather advisor
- Arrange the code Arrange the code: voting reminder
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the low-balance alert
Low-balance alert
- Coding task Heat alert
- Coding task Free delivery
- Coding task Student discount
Enroll to open this lesson -
Locked60 min
Lesson 4.2
if-else: two paths
else for the other path; exactly one block runs; pass/fail, even/odd and eligibility; common mistakes such as a condition after else.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: odd or even?
-
Concept video
Concept video: the railway junction
You just ran it · The railway junction · Real two-way decisions · The gap bug · Two classic mistakes · Recap
-
Notes
Notes: if-else
The railway junction · Real two-way decisions · The gap bug: why not two separate ifs? · Two classic mistakes · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: exactly 35
- Try it Investigate: two tracks
- Arrange the code Arrange the code: login check
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: else with a condition
else with a condition
- Coding task Pass or fail
- Coding task Larger of two
- Coding task Even or odd
Enroll to open this lesson -
Locked65 min
Lesson 4.3
elif ladders: many choices
elif for many choices; only the first true branch runs; why order matters; grade calculator; slab-based bills.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: a grade calculator
-
Concept video
Concept video: the college watchman
Why only Grade B? · The college watchman · Ladders in real life · The topper who got D · if vs elif · Recap
-
Notes
Notes: elif ladders
The college watchman · Real ladders · Order matters: the topper who got D · if vs elif inside a ladder · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: two grades
- Try it Investigate: be the watchman
- Arrange the code Arrange the code: traffic light
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the 20% that never comes
The 20% that never comes
- Coding task Grade calculator
- Coding task Cinema ticket price
- Coding task Discount slab
Enroll to open this lesson -
Locked65 min
Lesson 4.4
Nested conditions and combining logic
Nested if; when to nest and when to use and/or; guard checks; largest of three numbers; flattening deep nesting.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: a mini ATM
-
Concept video
Concept video: the ATM's two gates
You just ran it · Two gates · Nest or use and? · Arrow code and guard checks · Largest of three · Recap
-
Notes
Notes: nested conditions
The ATM's two gates · Nest, or use and? · Arrow code and guard checks · Largest of three (placement favourite) · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: the silent ATM
- Try it Investigate: test the ATM
- Arrange the code Arrange the code: driving check
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the wrong largest
The wrong largest
- Coding task Mini ATM
- Coding task Largest of three
- Coding task Driving check
Enroll to open this lesson -
Locked65 min
Lesson 4.5
Ternary expressions and match-case
The conditional expression x if condition else y; match-case with values, | for several values and _ as the default; when to use each.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: a one-liner and a phone menu
-
Concept video
Concept video: one-liners and phone menus
You just ran it · Your mother's one-liners · The customer-care menu · No break needed · Two common mistakes · When to use what
-
Notes
Notes: ternary expressions and match-case
The ternary: your mother's one-liners · match-case: the customer-care menu · For students who know C or Java · Which tool when? · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: the swapped result
- Try it Investigate: build your own IVR
- Arrange the code Arrange the code: a phone menu
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: invalid before you even press
Invalid before you even press
- Coding task One-line result
- Coding task Customer-care menu
- Coding task Weekday or weekend
Enroll to open this lesson -
Locked75 min
Lesson 4.6
Decision problems
Electricity bill slabs, triangle type, BMI category, leap year with if, ATM menu; planning decisions with flowcharts and testing boundary values.
ShowHide the 13 steps
- Notes Why this lesson matters
- Try it Run it first: an electricity bill
-
Concept video
Concept video: four real decision problems
Why not 2000? · Plan first · The slab bill · Triangle type · BMI category · Leap year with if · Recap
-
Notes
Notes: decision problems
Plan first: flowchart and boundary table · The slab electricity bill · Triangle type · BMI category · Leap year with if · Common confusions · Sources
-
Predict the output
Predict the output
2 questions
-
Fix the bug
Spot the difference
Spot the difference: the impossible triangle
- Try it Investigate: test like a professional
- Arrange the code Arrange the code: leap year ladder
-
Quick check
Quick check
5 questions
-
Fix the bug
Fix the bug: the overcharged customer
The overcharged customer
- Coding task Slab electricity bill
- Coding task Triangle type
- Coding task BMI category
Enroll to open this lesson
This module ends with a hands-on mini-project.