Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesPython FoundationsModule 3 · Functions and stringsParameters for installationwrite44 / 174
+75 XP
Task
📝 **Task:** `power(base, exp=2)` returns `base ** exp`. Default `exp = 2` (square). 📋 **Steps:** 1. `def power(base, exp=2):` 2. `return base ** exp` 3. `power(5)` → 25 4. `power(2, 3)` → 8 💡 **Similar example:** ```python def greet(name, msg="Hi"): return f"{msg}, {name}!" print(greet("Anna")) # "Hi, Anna!" print(greet("Anna", "Hello")) # "Hello, Anna!" ``` 🎯 **Expected output:** `25\n8`
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…