HW: Recursion I

Rx: <15 min Av: 15-30 min Sd: 30-45 min DNF: 45+ min

power.py

Write a function power which takes two numbers (base and exponent) as parameters and calculates the value base ** exponent using recursion by repeatedly multiplying base.

Next write a function power_loop which takes two numbers (base and exponent) as parameters and calculates the value base ** exponent using a loop.

Test that both functions return the same value when called with the same parameters.

steps.py

Write a function text_steps that takes a string as a parameter and recursively prints the text as follows:

Enter text: CS@DREW rocks!
CS@DREW rocks!
S@DREW rocks!
@DREW rocks!
DREW rocks!
REW rocks!
EW rocks!
W rocks!
 rocks!
rocks!
ocks!
cks!
ks!
s!
!

Test your function works by getting a string as input from the user.

For extra practice, try writing text_steps using a loop instead of recursion.

Submission

Once you’re satisfied that your programs are working correctly, take a screenshot of each program open in the editor, with its output displayed in the console, and submit to google classroom. You should submit 2 screenshots.