Problem Set on Functions


  1. Given the Python script below, determine what gets printed.
        def func_a():
            a = 2
            b = a + 3
            c = b * b
            return b + c
    
        print (func_a())
        
  2. Given the Python script below, determine what gets printed.
        def func_b(x):
            i = 0
            while x > 1:
                x = x / 2
                i = i + 1
            return i
    
        print (func_b(10.0))
        
    To think about: What is func_b approximating?

  3. Given the Python script below, determine what gets printed.
        def func_c(x = 0):
            if x < 0:
                return 'hello'
            elif x > 0:
                return 'world!'
            else:
                return ' '
    
        print(func_c(104) + func_c() + func_c(-11))