author | Nishanth <nishanth@fossee.in> |
Sun, 10 Oct 2010 16:00:59 +0530 | |
changeset 295 | c924eaf1b355 |
parent 241 | 2b2c94ee2c3e |
permissions | -rw-r--r-- |
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 |
|
295 | 20 |
Answer: only keyword arguments can be in any order, but should be called |
21 |
at the end. |
|
22 |
||
241
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
23 |
#. 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
|
24 |
values. |
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 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
27 |
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
|
28 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
29 |
if show: |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
30 |
print char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
31 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
32 |
return char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
33 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
34 |
Answer: ``count``, ``show`` |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
35 |
|
241
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
36 |
#. Given the following function, |
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 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
39 |
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
|
40 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
41 |
if show: |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
42 |
print char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
43 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
44 |
return char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
45 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
46 |
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
|
47 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
48 |
Answer: ``+`` is printed and returned. |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
49 |
|
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
50 |
|
241
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
51 |
#. Given the following function, |
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 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
54 |
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
|
55 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
56 |
if show: |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
57 |
print char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
58 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
59 |
return char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
60 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
61 |
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
|
62 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
63 |
Answer: ``+`` is printed and returned. |
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 |
#. Given the following function, |
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 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
68 |
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
|
69 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
70 |
if show: |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
71 |
print char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
72 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
73 |
return char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
74 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
75 |
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
|
76 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
77 |
Answer: SyntaxError |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
78 |
|
241
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
79 |
#. 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
|
80 |
:: |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
81 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
82 |
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
|
83 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
84 |
if show: |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
85 |
print char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
86 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
87 |
return char * count |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
88 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
89 |
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
|
90 |
defined at the end. |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
91 |
|
241
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
92 |
#. 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
|
93 |
arguments? |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
94 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
95 |
a. floats |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
96 |
#. lists |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
97 |
#. functions |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
98 |
#. booleans |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
99 |
#. None of the Above |
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 |
Answer: None of the above. |
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 |
Larger Questions |
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 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
107 |
1. |
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
108 |
|
2b2c94ee2c3e
Added questions to advanced features of functions LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
109 |
2. |