1 Objective |
1 Objective Questions |
2 --------- |
2 ------------------- |
3 |
3 |
4 .. A mininum of 8 questions here. |
4 .. A mininum of 8 questions here (along with answers) |
5 |
5 |
6 1. Question 1 |
6 1. All arguments of a function cannot have default values. True or |
7 2. Question 2 |
7 False? |
8 3. Question 3 |
8 |
|
9 Answer: False |
|
10 |
|
11 #. When calling a function, the arguments |
|
12 |
|
13 1. should always be in the order in which they are defined. |
|
14 #. can be in any order |
|
15 #. only keyword arguments can be in any order, but should be called |
|
16 at the beginning. |
|
17 #. only keyword arguments can be in any order, but should be called |
|
18 at the end. |
|
19 |
|
20 #. Given the following function, identify the keywords with default |
|
21 values. |
|
22 :: |
|
23 |
|
24 def seperator(char, count=40, show=False): |
|
25 |
|
26 if show: |
|
27 print char * count |
|
28 |
|
29 return char * count |
|
30 |
|
31 Answer: ``count``, ``show`` |
|
32 |
|
33 #. Given the following function, |
|
34 :: |
|
35 |
|
36 def seperator(char, count=40, show=False): |
|
37 |
|
38 if show: |
|
39 print char * count |
|
40 |
|
41 return char * count |
|
42 |
|
43 What is the output of ``separator("+", 1, True)``. |
|
44 |
|
45 Answer: ``+`` is printed and returned. |
9 |
46 |
10 |
47 |
11 Programming |
48 #. Given the following function, |
12 ----------- |
49 :: |
|
50 |
|
51 def seperator(char, count=40, show=False): |
13 |
52 |
14 .. A minimum of 2 questions here. |
53 if show: |
|
54 print char * count |
15 |
55 |
16 1. Programming Assignment 1 |
56 return char * count |
17 2. Programming Assignment 2 |
57 |
|
58 What is the output of ``separator("+", True, 1)``. |
|
59 |
|
60 Answer: ``+`` is printed and returned. |
|
61 |
|
62 #. Given the following function, |
|
63 :: |
|
64 |
|
65 def seperator(char, count=40, show=False): |
|
66 |
|
67 if show: |
|
68 print char * count |
|
69 |
|
70 return char * count |
|
71 |
|
72 What is the output of ``separator("+", show=True, 1)``. |
|
73 |
|
74 Answer: SyntaxError |
|
75 |
|
76 #. The following is a valid function definition. True or False? Why? |
|
77 :: |
|
78 |
|
79 def seperator(count=40, char, show=False): |
|
80 |
|
81 if show: |
|
82 print char * count |
|
83 |
|
84 return char * count |
|
85 |
|
86 Answer: False. All parameters with default arguments should be |
|
87 defined at the end. |
|
88 |
|
89 #. Which of the following cannot be used as default values for |
|
90 arguments? |
|
91 |
|
92 a. floats |
|
93 #. lists |
|
94 #. functions |
|
95 #. booleans |
|
96 #. None of the Above |
|
97 |
|
98 Answer: None of the above. |
|
99 |
|
100 |
|
101 Larger Questions |
|
102 ---------------- |
|
103 |
|
104 .. A minimum of 2 questions here (along with answers) |
|
105 |
|
106 1. |
|
107 |
|
108 2. |