Added questions for getting started with functions.
authorAnoop Jacob Thomas<anoop@fossee.in>
Wed, 10 Nov 2010 21:06:37 +0530
changeset 447 694309c7b43c
parent 446 2ce824b5adf4
child 448 b6c73309da70
Added questions for getting started with functions.
getting-started-with-functions/questions.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-with-functions/questions.rst	Wed Nov 10 21:06:37 2010 +0530
@@ -0,0 +1,112 @@
+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.