advanced-features-functions/questions.rst
author Puneeth Chaganti <punchagan@fossee.in>
Thu, 07 Oct 2010 12:28:12 +0530
changeset 242 a33e942379d7
parent 241 2b2c94ee2c3e
child 295 c924eaf1b355
permissions -rw-r--r--
Cleaned up script for getting started with files LO.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
241
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     1
Objective Questions
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     2
-------------------
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     3
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     4
.. A mininum of 8 questions here (along with answers)
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     5
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     6
1. All arguments of a function cannot have default values. True or
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     7
   False? 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     8
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     9
   Answer: False
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    10
   
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    11
#. When calling a function, the arguments 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    12
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    13
   1. should always be in the order in which they are defined.
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    14
   #. can be in any order
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    15
   #. only keyword arguments can be in any order, but should be called
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    16
      at the beginning.
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    17
   #. only keyword arguments can be in any order, but should be called
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    18
      at the end.
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
241
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    20
#. Given the following function, identify the keywords with default
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    21
   values. 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    22
   ::
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    23
   
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    24
     def seperator(char, count=40, show=False):
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    25
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    26
         if show:
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    27
             print char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    28
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    29
         return char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    30
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    31
   Answer: ``count``, ``show``
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
241
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    33
#. Given the following function, 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    34
   ::
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    35
   
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    36
     def seperator(char, count=40, show=False):
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    37
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    38
         if show:
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    39
             print char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    40
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    41
         return char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    42
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    43
   What is the output of ``separator("+", 1, True)``.
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    44
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    45
   Answer: ``+`` is printed and returned. 
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    46
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    47
241
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    48
#. Given the following function, 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    49
   ::
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    50
   
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    51
     def seperator(char, count=40, show=False):
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    52
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    53
         if show:
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    54
             print char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    55
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    56
         return char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    57
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    58
   What is the output of ``separator("+", True, 1)``.
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    59
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    60
   Answer: ``+`` is printed and returned. 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    61
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    62
#. Given the following function, 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    63
   ::
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    64
   
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    65
     def seperator(char, count=40, show=False):
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    66
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    67
         if show:
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    68
             print char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    69
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    70
         return char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    71
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    72
   What is the output of ``separator("+", show=True, 1)``.
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    73
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    74
   Answer: SyntaxError
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    75
241
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    76
#. The following is a valid function definition. True or False? Why?
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    77
   ::
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    78
   
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    79
     def seperator(count=40, char, show=False):
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    80
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    81
         if show:
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    82
             print char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    83
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    84
         return char * count
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    85
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    86
   Answer: False. All parameters with default arguments should be
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    87
   defined at the end. 
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    88
241
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    89
#. Which of the following cannot be used as default values for
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    90
   arguments? 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    91
     
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    92
   a. floats
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    93
   #. lists
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    94
   #. functions
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    95
   #. booleans
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    96
   #. None of the Above
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    97
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    98
   Answer: None of the above. 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    99
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   100
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   101
Larger Questions
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   102
----------------
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   103
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   104
.. A minimum of 2 questions here (along with answers)
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   105
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   106
1. 
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   107
2b2c94ee2c3e Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   108
2.