Phase 3 - Level 3: Pattern Recursion
Print patterns using recursion.
10 programs · open one, then the next
Start with Print Line of N Stars Recursively- 01Print Line of N Stars RecursivelyIntermediatePrint a line of n stars with a recursive function. Students trace printing before the next call and separate the terminating newline from repeated output.Open example →pydef print_stars(n): # Base case if n == 0: return
- 02Print Square of Stars RecursivelyIntermediateDraw a square with recursive row and star helpers. Students trace a row index, a width counter, and two distinct stopping conditions without nested loops.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 03Print Triangle (Top-Down) RecursivelyIntermediatePrint a growing triangle with recursive Python row helpers. Students trace output before the next row call and use a separate star function for each width.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 04Print Triangle (Bottom-Up) RecursivelyIntermediatePrint decreasing star rows by delaying work until recursive calls return. Students trace a row helper and compare return order with the growing-triangle version.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 05Number Patterns RecursivelyIntermediateGenerate increasing number rows with recursive helpers. Students separate a row-size function from a per-row number function and trace each helper's boundary.Open example →pydef print_numbers(n, current=1): # Base case if current > n: return
- 06Print Reverse Triangle RecursivelyIntermediatePrint a right-aligned shrinking triangle with recursion. Students trace row output during return and calculate leading spaces independently of star counts.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 07Multiplication Table RecursivelyIntermediatePrint a ten-row multiplication table through recursion. Students increment a multiplier argument and stop after ten while keeping the entered base unchanged.Open example →pydef print_table_row(n, multiplier=1): # Base case if multiplier > 10: return
- 08Increasing + Decreasing in One FunctionAdvancedPrint increasing then decreasing values with one recursive Python function. Students trace work before and after a call and avoid printing the peak twice.Open example →pydef print_inc_dec(n, current=1): # Base case if current > n: return
- 09Sum Series with Steps RecursivelyAdvancedSum a descending stepped series recursively. Students trace a nonpositive stopping condition and see why the step must move the argument toward that condition.Open example →pydef sum_series(n, step=1): # Base case if n <= 0: return 0
- 10Character Patterns RecursivelyAdvancedBuild alphabet rows with two recursive helpers. Students trace row counts, per-row character positions, and the base cases that bound both recursive paths.Open example →pydef print_chars(n, current=0): # Base case if current >= n: return