Week 12: Recursion

Week 12 Goals

  • Wrap up sorting

  • Learn recursion, an alternative to iteration for repetition

  • Practice writing recursive functions

Week 12 Code

  • printmessage.py: A recursive example program that repeats a message.

  • countdown.py: A recursive program to analyze and discuss.

  • factorial.py: Recursive exercise to implement a factorial function.

  • list_reverse.py: Recursive exercise to reverse a list.

  • count_letter.py: Recursive exercise to count how many times a character appears in a string.

  • power.py: Recursive exercise to write a function that raises a number to a power.

  • sorted.py: Recursive exercise to determine if a list is in sorted order.