# HG changeset patch # User Puneeth Chaganti # Date 1286383533 -19800 # Node ID 2b2c94ee2c3e58ab5b6d3ac4c9cdaca54cbb2092 # Parent f4c36aa38a844ba6b04f0cf8bd3bc593ba061a1e Added questions to advanced features of functions LO. diff -r f4c36aa38a84 -r 2b2c94ee2c3e advanced-features-functions/questions.rst --- a/advanced-features-functions/questions.rst Wed Oct 06 19:32:18 2010 +0530 +++ b/advanced-features-functions/questions.rst Wed Oct 06 22:15:33 2010 +0530 @@ -1,17 +1,108 @@ -Objective ---------- +Objective Questions +------------------- + +.. A mininum of 8 questions here (along with answers) + +1. All arguments of a function cannot have default values. True or + False? + + Answer: False + +#. When calling a function, the arguments + + 1. should always be in the order in which they are defined. + #. can be in any order + #. only keyword arguments can be in any order, but should be called + at the beginning. + #. only keyword arguments can be in any order, but should be called + at the end. -.. A mininum of 8 questions here. +#. Given the following function, identify the keywords with default + values. + :: + + def seperator(char, count=40, show=False): + + if show: + print char * count + + return char * count + + Answer: ``count``, ``show`` -1. Question 1 -2. Question 2 -3. Question 3 +#. Given the following function, + :: + + def seperator(char, count=40, show=False): + + if show: + print char * count + + return char * count + + What is the output of ``separator("+", 1, True)``. + + Answer: ``+`` is printed and returned. -Programming ------------ +#. Given the following function, + :: + + def seperator(char, count=40, show=False): + + if show: + print char * count + + return char * count + + What is the output of ``separator("+", True, 1)``. + + Answer: ``+`` is printed and returned. + +#. Given the following function, + :: + + def seperator(char, count=40, show=False): + + if show: + print char * count + + return char * count + + What is the output of ``separator("+", show=True, 1)``. + + Answer: SyntaxError -.. A minimum of 2 questions here. +#. The following is a valid function definition. True or False? Why? + :: + + def seperator(count=40, char, show=False): + + if show: + print char * count + + return char * count + + Answer: False. All parameters with default arguments should be + defined at the end. -1. Programming Assignment 1 -2. Programming Assignment 2 +#. Which of the following cannot be used as default values for + arguments? + + a. floats + #. lists + #. functions + #. booleans + #. None of the Above + + Answer: None of the above. + + +Larger Questions +---------------- + +.. A minimum of 2 questions here (along with answers) + +1. + +2. diff -r f4c36aa38a84 -r 2b2c94ee2c3e advanced-features-functions/script.rst --- a/advanced-features-functions/script.rst Wed Oct 06 19:32:18 2010 +0530 +++ b/advanced-features-functions/script.rst Wed Oct 06 22:15:33 2010 +0530 @@ -15,7 +15,6 @@ .. 1. getting started with ipython .. #. getting started with functions -.. #. getting started with functions .. Author : Puneeth Internal Reviewer :