getting-started-with-functions/questions.rst
changeset 447 694309c7b43c
equal deleted inserted replaced
446:2ce824b5adf4 447:694309c7b43c
       
     1 Objective Questions
       
     2 -------------------
       
     3 
       
     4 .. A mininum of 8 questions here (along with answers)
       
     5 
       
     6 1. What will the function do?
       
     7    ::
       
     8 
       
     9        def what(x)
       
    10            return x*x
       
    11 
       
    12    1. Returns the square of x
       
    13    #. Returns x
       
    14    #. Function doesn't have docstring
       
    15    #. Error	   
       
    16 
       
    17    Answer: Error
       
    18 
       
    19 2. What will the function do?
       
    20    ::
       
    21 
       
    22        def what(x):
       
    23            return x*x
       
    24 
       
    25    1. Returns the square of x
       
    26    #. Returns x
       
    27    #. Function doesn't have docstring
       
    28    #. Error	   
       
    29 
       
    30    Answer: Returns the square of x
       
    31 
       
    32 3. How many arguments can be passed to a python function?
       
    33 
       
    34    1. None
       
    35    #. One
       
    36    #. Two
       
    37    #. Any
       
    38 
       
    39    Answer: Any
       
    40 
       
    41 4. How many values can a python function return?
       
    42 
       
    43    1. None
       
    44    #. One
       
    45    #. Two
       
    46    #. Any
       
    47 
       
    48    Answer: Any
       
    49 
       
    50 5. A python function can return only one value
       
    51 
       
    52    1. True
       
    53    #. False
       
    54 
       
    55    Answer: False
       
    56 
       
    57 6. What will be the output of the following code?
       
    58    ::
       
    59 
       
    60        def avg(a, b):
       
    61        	   return (a + b) / 2
       
    62 
       
    63        print avg(10,11)
       
    64 
       
    65    1. 10
       
    66    #. 10.5
       
    67    #. 11
       
    68    #. 9.5
       
    69 
       
    70    Answer: 10
       
    71 
       
    72 7. What will be the output of the following code?
       
    73    ::
       
    74 
       
    75        def avg(a, b):
       
    76        	   return (a + b) / 2
       
    77 
       
    78        print avg(10,11.0)
       
    79 
       
    80    1. 10
       
    81    #. 10.5
       
    82    #. 11
       
    83    #. 9.5
       
    84 
       
    85    Answer: 10.5
       
    86 
       
    87 8. What will be the output of the following code?
       
    88    ::
       
    89 
       
    90        def what(a, b):
       
    91        	   return a + b / 2
       
    92 
       
    93        print avg(10,11)
       
    94 
       
    95    1. 10
       
    96    #. 10.5
       
    97    #. 16
       
    98    #. 15
       
    99 
       
   100    Answer: 15
       
   101 
       
   102 
       
   103 Larger Questions
       
   104 ----------------
       
   105 
       
   106 .. A minimum of 2 questions here (along with answers)
       
   107 
       
   108 1. Write a python function to check the numbers a, b c is a Pythagorean
       
   109    triplet or not.
       
   110 
       
   111 2. Write a python function which will accept an n digit number and
       
   112    which returns the reverse of the number.