getting-started-with-functions/questions.rst
author bhanu
Mon, 15 Nov 2010 15:00:34 +0530
changeset 503 a858141ad884
parent 447 694309c7b43c
permissions -rw-r--r--
Language check done for `I/O`

Objective Questions
-------------------

.. A mininum of 8 questions here (along with answers)

1. What will the function do?
   ::

       def what(x)
           return x*x

   1. Returns the square of x
   #. Returns x
   #. Function doesn't have docstring
   #. Error	   

   Answer: Error

2. What will the function do?
   ::

       def what(x):
           return x*x

   1. Returns the square of x
   #. Returns x
   #. Function doesn't have docstring
   #. Error	   

   Answer: Returns the square of x

3. How many arguments can be passed to a python function?

   1. None
   #. One
   #. Two
   #. Any

   Answer: Any

4. How many values can a python function return?

   1. None
   #. One
   #. Two
   #. Any

   Answer: Any

5. A python function can return only one value

   1. True
   #. False

   Answer: False

6. What will be the output of the following code?
   ::

       def avg(a, b):
       	   return (a + b) / 2

       print avg(10,11)

   1. 10
   #. 10.5
   #. 11
   #. 9.5

   Answer: 10

7. What will be the output of the following code?
   ::

       def avg(a, b):
       	   return (a + b) / 2

       print avg(10,11.0)

   1. 10
   #. 10.5
   #. 11
   #. 9.5

   Answer: 10.5

8. What will be the output of the following code?
   ::

       def what(a, b):
       	   return a + b / 2

       print avg(10,11)

   1. 10
   #. 10.5
   #. 16
   #. 15

   Answer: 15


Larger Questions
----------------

.. A minimum of 2 questions here (along with answers)

1. Write a python function to check the numbers a, b c is a Pythagorean
   triplet or not.

2. Write a python function which will accept an n digit number and
   which returns the reverse of the number.