Command Palette

Search for a command to run...

Hectal
Phase 5: Functions
Python · Exercise 6 of 6 Previous
Intermediate

Power with recursion

Write a recursive function power(base, exponent) for whole-number exponents of 0 or more. Do not use ** or loops.

power(2, 0) is 1.

What Check tests

  1. power(2, 10) is 1024
  2. power(5, 0) is 1
  3. power(3, 1) is 3
  4. The function calls itself
  5. A deeper call works
  6. A zero base is fine
  7. No loops and no ** in your function

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.