# HG changeset patch # User Anoop Jacob Thomas # Date 1289403397 -19800 # Node ID 694309c7b43cb32d05aa7901d5e0ed4728646977 # Parent 2ce824b5adf4909a1fa856702596e82ec1bc1f63 Added questions for getting started with functions. diff -r 2ce824b5adf4 -r 694309c7b43c 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.