# Lab 7 - Exercise 1 - Problem 4 def magic(aNumber, aSymbol, end): print(aSymbol * aNumber) if aNumber <= end : magic(aNumber+1, aSymbol, end) print(aSymbol * aNumber) return # Main part of the program magic( 3, "*", 7) print("Wow!") # c) What happens when we call magic() with the argument 10 instead of 3? magic( 10, "*", 7) print("Wow!") # a) Base case is implicit (i.e., not written in the program) -> "if aNumber > end : return" # Recursive case -> "magic(aNumber+1, aSymbol)" # # What is the difference between the base case and recursive case of this function magic() # and the base case and recursive case of the function magic() in Problem 2 above? # # Answer: The recursive case of Problem 4 (above) increased the variable # aNumber in the recursive case and the recursive calls stopped when aNumber # exceeded the large number 7, while the recursive case of Problem 2 decreased # the variable aNumber in the recursive case and the # recursive calls stopped when aNumber became smaller than 1 # b) How many times is the function magic( ) in the above program called? 6 times # c) What happens when we call magic() with the argument 10 instead of 3? # The base case is reached during the first and only call to magic( ). # Output: # ********** # Wow!