COP4521 Homework 1 Name: FSU login: 1 (10 points). The content of file aa.py is as follows: -- print("aa.py Top level", __name__) def hello(): print("Hello from", __name__) -- The content of file bb.py is as follows: -- import aa print("bb.py Top level", __name__) aa.hello() -- What is the output when we run bb with 'python3 bb.py' on linprog? (5 points) Explain why each line is printed as it is (5 points) 2 (10 points). Consider the following code segment: def addObj(a, b): a.append(b) print('Inside 1: a = ', a) a = a + [b] print('Inside 2: a = ', a) lst = [1, 2, 3] addObj(lst, 100) print('Outside: lst = ', lst) What is the output when the code segment is executed? (5 points) Explain why each line is printed as it is (5 points) 3. (10 points) Let a function prototype be def foo(arg1, arg2, arg3, arg4 = 1, arg5 = "one"): Which of the following function calls are valid in python: foo('aaa', 'bbb', 'ccc') foo(arg2 = 'bbb', arg1 = 'aaa', 'bbb') foo('aaa', 'ccc', arg5='ddd', arg2='bbb') foo('aaa', arg3 = 'bbb', arg2 = 'ccc', arg5='ddd') foo(arg5 = 'eee', arg4 = 2, arg3 = 'ccc', arg2 = 'bbb', arg1 = 'bbb') 4. (10 points) Write a function that can take any number of positional arguments followed by any number of keyword arguments. The function then prints the last positional argment and the last keyword arguments. 5 (20 points). Let the content of foo.py be the following: ------------ count = 0 def printUpdateCount(): print(count) for i in range (0, 4): count = 4 print(count) printUpdateCount() ------------- What is the output when you run the code with 'python3 foo.py' on linprog (10 points)? Explain your answer (10 points) 6 (20 points). What is the output of the following code segment when executed (10 points)? Briefly explain (10 points). def aaa(x): def bbb(y): c = x * x return c * y return bbb area10 = aaa(10) print(area10(3)) print(area10(5)) 7 (20 points). Let a sequence of numbers be 5, 5, 3, 7, 1, 9, ... More precisely, the first three numbers are x_1= 5, x_2=5, and x_3 = 3. Following that x_i = x_{i-3} + x_{i-2} - x_{i-1}. For example, x_4 = x_1 + x_2 - x_3 = 5 + 5 - 3 = 7; x_5 = x_2 + x_3 - x_4 = 5 + 3 - 7 = 1; and so on. Write a generator for this sequence.