0% complete
First-year college Campus track — resume-grade projects.
Chapter 1 of 13 14 min
Python depth: functions & errors
Story
Aanya and Vihaan reach a new challenge: "Python depth: functions & errors". Think about safe average.
Pixel beeps: "Don't just read about it — let's learn by DOING. Try the demo below! "
The idea
Write robust functions. Good functions do one thing, return clear values, and handle edge cases. Default arguments and *args make them flexible.
Handle errors. try/except lets your code recover from bad input instead of crashing — essential for real tools.
Indian-life example — Safe average
def average(nums): return sum(nums)/len(nums) if nums else 0 — handles an empty list gracefully.
Interactive demo — do it yourself
Pixel · Step 1 of 4
Tap a Mango, then tap the Mango box.
Mango (0)
Orange (0)
Practice — your turn
A good function does…
try.py
Python sandboxTerminal
› Click Run to execute. First run loads Python (~6s).
Recap
- Write robust functions
- Handle errors
+15 XP on complete
Finish the demo and practice above to continue.