Compsci 101, Fall 2014, Classwork Nov 25

Put the answers to problems 1-4 in this form

Problem 1:

Consider the Mystery function.

def Mystery(num): if num > 0: return 1 + Mystery(num/2) else: return 2 + num What is Mystery(2)? What is Mystery(4)? What is Mystery(8)? What is Mystery(17)?

Problem 2:

Write SumUpEvens(data) recursively.

def SumUpEvensRec(data): # data is a list of integers

Problem 3:

See the three functions PrintOnePerLine. What is the output for each of them?

Problem 4:

See Fibonacci What is the output for Fibonacci(6)? For Fibonacci(10)? Is it possible to compute Fibonacci(50)?