Page 290 - Computer Science Class 11 With Functions
P. 290

2. Consider the following function definition:
              def practice(num1,num2=0):
                  print(num1,num2)
              Which of the following function call statements will result in an error?
              a.  def practice()       b. def practice(var1)   c. def practice(var2,var1)  d. def practice(var1,var2)

           3.  Which of the following function headers will not generate a syntax error?
              a.  def test(p = 0, q):
              b.  def test(p = 0, q, r = 1):
              c.  def test(p, q, r = 1)
              d.  def test(p = 0, q = 1, r):
          4. Which of the following function calls will cause an error while invoking the function defined below?
              def myFunc(a,b,c,d):
                  return a + b + c + d
              a.  myFunc(a = 4, 3, 2, 1)
              b.  myFunc(d = 4, c = 3, b = 2, a = 1)
              c.  myFunc(4, 3, 2, 1)
              d.  myFunc(4, b = 3, c = 2, d = 1)
          5. Consider the following code:

              def testFunc(a, b, c = 6):
                   print(a, b, c)
              testFunc(c = 20,a = 5, b = 10)
              Which of the following will be produced as output on execution of the above code?
              a.  5 10 20              b. 20 5 10             c. 5 20 10             d. Error
           6.  Consider the code given below:
              def testFunc(a1, a2, a3 = 6):
                  return  a1 + a2 + a3
              testFunc(a3 = 20, a1 = 5, a2 = 10)    # Statement 1
              testFunc(20, 5)                   # Statement 2
              Which of the following statements is true?
              a.  Statement 1 will not execute as the arguments are not in the same order as parameters.
              b.  Statement 2 will not execute as third argument is missing
              c.  Statement 1 will execute as it is called with keyword arguments
              d.  Statement 2 will execute as it is called with keyword arguments

           7.  Consider the following function definition.
              def testFunc(a, b, c = 6):
                  return str(a) + ' ' + str(b) + ' ' + str(c)
              Which of the following is an incorrect call to the function testFunc defined above?
              a. testFunc('Correct')
              b. testFunc(10, 'correct', 'value')
              c. testFunc('correct', 'value')
              d. testFunc(10, 50)
        B.  State whether the following statements are True or False:
           1.  Keyword arguments may sometimes be specified without using the names of dummy arguments.   __________
           2.  The randrange(start, stop=None, step=1) function of the random module enables
              us to generate a random number between start and stop, not including stop.               __________
           3.  Python module math enables us to compute statistical quantities like mean, median, and mode.   __________

         288   Touchpad Computer Science-XI
   285   286   287   288   289   290   291   292   293   294   295