important question of working with function class 12

important questions of
working with function

working with function

Q 1. what data type is object below?

sol. tuple

Q 2.which python library need to be imported to use following function?

           (1)float()             (2)randint()
sol.  (1)built-in (no module)
          (2) random module

Q 3. which of the following is valid arithmetic operator in python?

    (1)//         (2)?      (3)<         (4)and
sol. (1)//

Q 4. would expression 3**1**3 and 3*1**3 evaluate to same result(true/false)?

sol.  true

Q 5. which of the following expressions results in an error?

   (1)float(’12’)     (2)int(’12’)    (3)float(‘12.5’)     (4)int(‘12.5’)
sol. (d) int(‘12.5’)

Q 6. from the program code given below,identify the parts mentioned                           below.

        def  processnumber(x):
                return x=3
identify these parts: function header,function call,argument,parameter,function body,main program.
sol.  function header: def  processnumber(x):
        function call:  processnumber(y)
        argument:    y
        parameter:   x
        function body:   x=72
                                     return x=3
        main program:    y=54

Q 6. find output of the code.

  def   power(b,p):
                  return y
         def   calcsquare(x):
                   return a
         result=calcsquare(n) + power(3,3)
sol.  output

Q 7. what is the difference between the formal parameter and actual parameter.

sol. actual parameter:- is a parameter,which is used in function call statement to send the value from the calling function to the called function. it is known as argument.
formal parameter:- is a parameter,which is used in function header of the called function to receive the value from the actual is also known as parameter.

Q 8. what is the default return value for a function that does not return any value explicitly.

      (a)none    (b)int       (c)double     (d) null
sol. (a)none

Q 9. which names are local,which are global and which are built-in in the following code fragment.

           invaders=”big names”
         def   play():
                  max_level=level + 10
sol.  global names:-   invaders,pos,level,res
        local names:-max_level
       built_in:-  len

Q 10. predict the output.

 def  func(message,num+1):
sol.  output

Q 11. find output of the code.

           def  f():
sol.  output

Q 12. find output of the code.

            def check(n1=1,n2=2):
sol.  output
        3  3
        3   2
       5   3

Q 13. is return statement optional? compare and comment on the following two return statement.
return val

sol. the return statement is optional only when the function is void or we can say that when the function does not return a value.a function that return a value,must have at-least one one return from given two return statements,statement.
is not returning any value,rather it returns the control to caller along with empty value none.and the statement.
return val
is returning the control to caller along with the value contained in variable val.

Q 14. write function that takes a positive integer and returns the one’s position digit of the integer.

sol. def  getones(num):
               #return the ones digit of the intiger num
               return onesdigit

Q 15.what is the possible outcomes executed from the following code?also specify the maximum and minimum values that can be assigned to variable number.

    while string[n] != ‘L’ :
               print(string[n]+string[number]+’#’,end=’ ‘)
 (1)ES#NE#IO#        (2)LE#NO#ON#      (3)NS#IE#LO#       (4)EC#NB#IS#
sol. part (4) can be one of possible outcomes.
        maximum value 3,minimum value 0.

working with function notes