Page 3 - HA
P. 3

Home Assignment

               6)  What will be the output of the following code:
                   def PRINT(S, a):
                       return(a*S)
                   X='Hello'
                   A=PRINT(3, X)
                   Print(A+X)

               7)  Can a function return multiple values in python? Explain through a code using Python.


               C) Answer the following questions:
               1.   What is the output of the following code snippet?
                   def func(x = 1, y = 2):
                        x = x + y
                        y += 1
                        print(x, y)
                   func(y = 2, x = 1)
                   A. 1 3
                   B. 2 3
                   C. The program has a runtime error because x and y are not defined.
                   D. 3 2
                   E. 3 3

               2.   What is the output of the following code snippet?
                   num = 1
                   def func():
                        num = 3
                        print(num, end=' ')
                   func()
                   print(num)
                   A. 1 3
                   B. 3 1
                   C. The program has a runtime error because x is not defined.
                   D. 1 1
                   E. 3 3

               3.   What is the output of the following code snippet?
                   num = 1
                   def func():
                        num = num + 3
                        print(num)
                   func()
                   print(num)
                   A. 1 4
                   B. 4 1
                   C. The program has a runtime error because the local variable ‘num’ referenced before
                   assignment.
                   D. 1 1
                   E. 4 4

               4.   What is the output of the following code snippet?
                   def test(x = 1, y = 2):
   1   2   3   4   5   6