Page 263 - Computer Science V2.0 Class 11
P. 263

10.  Which of the following statements is not true with respect to functions in Python?
                      a.  By default, the arguments in a function call are specified in the same sequence as in the formal parameter list.
                      b.  Python allows us to specify  the input arguments to  a function in an arbitrary order by explicitly associating the names
                         of the formal parameters with their values
                      c.  When a user specifies the values of the default parameters, the default values are ignored.
                      d.  The values assigned to the formal parameters during the function call, are called the default values of the parameters.

                 B.  State whether the following statements are True or False:
                    1.  A Python module is a file comprising Python code.                                      __________
                    2.  import keyword is used to import a specific function into a Python program.            __________
                    3.  pow() is defined in math module.                                                       __________
                    4.  All default parameters (if any) should precede the non-default parameters.             __________
                    5.  A function can be passed as an argument to another function.                           __________
                 C.  Fill in the blanks.
                    1.  Once a module is imported, we can use all the functions defined in the module by preceding the function name by the
                      name of the module and a _________ operator.
                    2.  _______ module provides several functions for random number generation.
                    3.  The function, floor() of math module takes an integer or floating-point number as the input and returns the ____________
                      integer greater than or equal to the argument.
                    4.  The random() function of the random module enables us to generate a random number between _________and _________.
                    5.  During function definition, if a parameter takes a default value, then all the other parameters to its _____________ must
                      also take default values.
                 D.  Answer the following questions:
                    1.  Differentiate between the default arguments and keyword arguments.
                    2.  Consider the following function header of the function responsible for multiplying three numbers:
                      def multiply(num1, num2 = 5, num3 = 6):
                      Give suitable function calls to specify the below-mentioned arguments while other arguments take default values:
                      a.  num1 = 6, num3 = 7
                      b.  num1 = 4

                    3.  Consider the following function header:
                      def testCall(num1, num2 = 10, num3 = 100):
                      Which of the following function call statements will be executed correctly? Justify your answer.
                      (a) testCall(20)
                      (b) testCall(num2 = 20)
                      (c)  testCall(num2 = 20,num1 = 30)
                      (d) testCall(50,500,5000)
                      (e) testCall()
                      (f)  testCall(val,num3 = 50) ( Assume val=500)
                      (g) testCall(num3 = 50,num1 = 500)
                   4. Predict the output of the codes given below:
                       (i)  def myfunc(arg1 = 2, arg2 = 3):

                              arg1 = arg1 + arg2
                              arg2 = arg1 - arg2
                              print(arg1, "###",arg2)
                              return arg1
                          P = 10

                                                                                                           Modules    249
   258   259   260   261   262   263   264   265   266   267   268