Skip to main content
← CoursesPython FoundationsModule 3 · Functions and stringsParameters for installationwrite42 / 170
💬 Discuss🧪 Playground+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`

Keep going

✏️ Write your code here
🐍
Loading Python...
First visit only — ~5-10s. Stays cached afterward.
📊 Result
Press Run to see result...
📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

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