- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex2.html
More file actions
Latest commit
368 lines (343 loc) · 14.7 KB
/
Copy pathindex2.html
File metadata and controls
368 lines (343 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"></html>
<head>
<title>Python 2 Term Quiz</title>
<metahttp-equiv="Content-Type" content="text/html; charset=utf-8" />
<metahttp-equiv="Content-Language" content="en" />
<metaname="robots" content="index,follow" />
<linkrel="stylesheet" type="text/css" href="./resources/css.css" media="screen" />
<linkrel="stylesheet" type="text/css" href="./resources/code.css" media="screen, print" />
<linkhref='./resources/print_stylesheet.css' rel='stylesheet' type='text/css' media='print' />
<scriptsrc="./resources/AC_QuickTime.js" language="javascript" type="text/javascript"></script>
<scriptsrc="./resources/common.js" language="javascript" type="text/javascript"></script>
<scriptsrc="./jsFiles/unitData.js" language="javascript" type="text/javascript"></script>
<scriptsrc="./jsFiles/exercises-4.js" language="javascript" type="text/javascript"></script>
<scripttype="text/javascript" src="./resources/shCore.js"></script>
<scripttype="text/javascript" src="./resources/shBrushJScript.js"></script>
<scripttype="text/javascript" src="./resources/shBrushPlain.js"></script>
<scripttype="text/javascript" src="./resources/shBrushXml.js"></script>
<linktype="text/css" rel="stylesheet" href="./resources/shCore.css"/>
<linktype="text/css" rel="stylesheet" href="./resources/shThemeDefault.css"/>
<scripttype="text/javascript">
SyntaxHighlighter.config.clipboardSwf='./resources/clipboard.swf';
SyntaxHighlighter.all();
</script>
</head>
<body>
<divid="center">
<divid="border">
<divid="logo" class="noprint">
Introduction to Programming - Python<br>
Author: <b>Lucy</b>
</div>
<divstyle="font:1.3em geneva,arial,sans-serif;" class="noview">
Introduction to Python 2
<hr/>
</div>
<divclass="noprint">
<pclass="heading">
<astyle="color:#999;font-weight:bold;" href="#" /><imgsrc="./resources/home_24.png" />Python</a>
<imgsrc="./resources/arrow_right_small.png" />Introduction to Python <hr/>
</p>
</div>
<divid="main">
<h1>Quiz : Fundemental Python 2<hr/></h1></div>
<divclass="noprint">
<h2>Part 1: Multiple Choice</h2>
<ol>
<li>What is the value of the following expression?</li>
<blockquote>
<code>print(25/5)<br></code>
</blockquote><br>
<formid = "form1" action="">
<inputtype="radio" name="1" value="a">a. 5.0<br>
<inputtype="radio" name="1" value="b">b. 5<br>
<inputtype="radio" name="1" value="c">c. error<br>
<br>
<inputtype="button" onclick="myFunc1()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput1" size="50"></div>
</form><br>
<li>What is the value of the following expression?</li>
<blockquote>
<code>print(-28//5)<br></code>
</blockquote><br>
<formid = "form2" action="">
<inputtype="radio" name="1" value="a">a. -5<br>
<inputtype="radio" name="1" value="b">b. 5<br>
<inputtype="radio" name="1" value="c">c. -6<br>
<inputtype="radio" name="1" value="d">d. 6<br>
<br>
<inputtype="button" onclick="myFunc2()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput2" size="50"></div>
</form><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>def output(**args):<br> for i in args:<br> print(i)<br>output(name = "Alice", id = 007)<br></code>
</blockquote><br>
<formid = "form3" action="">
<inputtype="radio" name="1" value="a">a. Alice<br> 007<br>
<inputtype="radio" name="1" value="b">b. ('name', 'Alice')<br> ('id', 007)<br>
<inputtype="radio" name="1" value="c">c. name<br> id<br>
<inputtype="radio" name="1" value="d">d. TypeError<br>
<br>
<inputtype="button" onclick="myFunc3()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput3" size="50"></div>
</form><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>def output(*args):<br> for i in args:<br> print(i)<br>output(name = "Alice", id = 007)<br></code>
</blockquote><br>
<formid = "form3" action="">
<inputtype="radio" name="1" value="a">a. Alice<br> 007<br>
<inputtype="radio" name="1" value="b">b. ('name', 'Alice')<br> ('id', 007)<br>
<inputtype="radio" name="1" value="c">c. name<br> id<br>
<inputtype="radio" name="1" value="d">d. TypeError<br>
<br>
<inputtype="button" onclick="myFunc3_1()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput3_1" size="50"></div>
</form><br>
<li>What is the output of the add() function call?</li>
<blockquote>
<code>def add(x, y):<br> return x+3, y+5<br>output = add(1, 2)<br>print(output)
<br></code>
</blockquote><br>
<formid = "form4" action="">
<inputtype="radio" name="1" value="a">a. 11<br>
<inputtype="radio" name="1" value="b">b. 4<br>
<inputtype="radio" name="1" value="c">c. Syntax Error<br>
<inputtype="radio" name="1" value="d">d. (4, 7)<br>
<br>
<inputtype="button" onclick="myFunc4()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput4" size="50"></div>
</form><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>def first(a, b):<br>
def second(c, d):<br>
return c + d<br>
return second(a, b)<br>
return a<br>
res = first(10, 20)<br>
print(res)
<br></code>
</blockquote><br>
<formid = "form5" action="">
<inputtype="radio" name="1" value="a">a. 10<br>
<inputtype="radio" name="1" value="b">b. 30<br>
<inputtype="radio" name="1" value="c">c. 30 10<br>
<inputtype="radio" name="1" value="d">d. (30, 10)<br>
<inputtype="radio" name="1" value="d">e. Syntax Error<br>
<br>
<inputtype="button" onclick="myFunc5()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput5" size="50"></div>
</form><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>myTuple = (10, 20, 30, 40, 50)<br>
myTuple[1] = 25<br>
print(myTuple)
<br></code>
</blockquote><br>
<formid = "form6" action="">
<inputtype="radio" name="1" value="a">a. (10, 25, 30, 40, 50)<br>
<inputtype="radio" name="1" value="b">b. (25, 20, 30, 40, 50)<br>
<inputtype="radio" name="1" value="c">c. (10, 20, 30, 40, 50)<br>
<inputtype="radio" name="1" value="d">d. TypeError<br>
<br>
<inputtype="button" onclick="myFunc6()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput6" size="50"></div>
</form><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>set1 = {10, 20, 30, 40}<br>
set2 = {'10', 50, '60', 70}<br>
set3 = set1.union(set2)<br>
print(set3)
<br></code>
</blockquote><br>
<formid = "form7" action="">
<inputtype="radio" name="1" value="a">a. {40, 50, 20, 30, 10, 60, 70}<br>
<inputtype="radio" name="1" value="b">b. {40, 50, 20, 30, 10, 60, '10', 70}<br>
<inputtype="radio" name="1" value="c">c. {40, 50, 20, 30, '10', 60, 70}<br>
<inputtype="radio" name="1" value="d">d. SyntaxError<br>
<br>
<inputtype="button" onclick="myFunc7()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput7" size="50"></div>
</form><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>shapeSet = {'triangle','circle','hexagon','pantagon'}<br>
print(shapeSet[1])
<br></code>
</blockquote><br>
<formid = "form8" action="">
<inputtype="radio" name="1" value="a">a. circle<br>
<inputtype="radio" name="1" value="b">b. triangle<br>
<inputtype="radio" name="1" value="c">c. 'circle'<br>
<inputtype="radio" name="1" value="d">d. SyntaxError<br>
<br>
<inputtype="button" onclick="myFunc8()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput8" size="50"></div>
</form><br>
<li>Which is true for Python function?</li>
<formid = "form9" action="">
<inputtype="checkbox" name="1" value="a">a. A function can return only a single value<br>
<inputtype="checkbox" name="1" value="b">b. A function can take an unlimited number of arguments<br>
<inputtype="checkbox" name="1" value="c">c. A function can return multiple values<br>
<inputtype="checkbox" name="1" value="d">d. A function doesn't return anythin unless add a return statement<br>
<inputtype="checkbox" name="1" value="e">e. A function is a code block that only executes when it is called<br>
<inputtype="checkbox" name="1" value="f">f. A function always returns a value<br>
<inputtype="checkbox" name="1" value="g">g. A function can be reused in a program<br>
<inputtype="checkbox" name="1" value="h">h. Python doesn't support nested function<br>
<br>
<inputtype="button" onclick="myFunc9()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput9" size="50"></div>
</form><br>
<li>Which is true for Python tuple?</li>
<formid = "form10" action="">
<inputtype="checkbox" name="1" value="a">a. A tuple maintains the order of items<br>
<inputtype="checkbox" name="1" value="b">b. A tuple is unordered<br>
<inputtype="checkbox" name="1" value="c">c. We cannot change the tuple once created<br>
<inputtype="checkbox" name="1" value="d">d. We cannot remove items from the tuple<br>
<inputtype="checkbox" name="1" value="e">e. We cannot delete the tuple<br>
<inputtype="checkbox" name="1" value="f">f. We cannot update items of the tuple<br>
<inputtype="checkbox" name="1" value="g">g. A tuple can be created without using parentheses<br>
<br>
<inputtype="button" onclick="myFunc10()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput10" size="50"></div>
</form><br>
<li>Which is true for Python set?</li>
<formid = "form11" action="">
<inputtype="checkbox" name="1" value="a">a. Set is unordered<br>
<inputtype="checkbox" name="1" value="b">b. Set does not allow duplicate<br>
<inputtype="checkbox" name="1" value="c">c. Set is around by curly braces<br>
<inputtype="checkbox" name="1" value="d">d. Set is immutable<br>
<inputtype="checkbox" name="1" value="e">e. Set supports indexing<br>
<br>
<inputtype="button" onclick="myFunc11()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput11" size="50"></div>
</form><br>
</ol></div>
<divclass="noprint">
<h2>Part 2: Complete input field</h2>
<ol>
<li>What is the output of the following function call?</li>
<blockquote>
<code>def first(a, b):<br>
def second(c, d):<br>
return c + d<br>
return second(a, b)<br>
res = first(10, 20)<br>
print(res)<br>
</code>
</blockquote><br>
<inputtype="text" id="input2_1" size="50" required><spanid="sp21" class="tick"></span><br>
<inputtype="button" onclick="myFunc2_1()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput2_1" size="50"></div>
<br>
<li>What is the output of the code?</li>
<blockquote>
<code>
x = [1,2]<br>
y = x<br>
y += [3,4]<br>
print(x, end=' ')<br>
print(y)<br>
</code>
</blockquote>
<inputtype="text" id="input2_2" size="50" required><spanid="sp22" class="tick"></span><br>
<div><inputtype="button" onclick="myFunc2_2()" value="SUBMIT"></div><br>
<divclass="divOutput" id="divOutput2_2" size="50"></div>
<!--<div>
<ul>
<li>Sample Output:</li><br>
</ul>
<div class="blackGreen" style="background-color:#444;">
<p style="color:#22FF22;">Enter the first number: 20<br>Enter the second number: 30<br>The sum is 50</p>
</div>
</div>--><br>
<li>What is the output of the following code?</li>
<blockquote>
<code>
myTuple = (10, 20, 30, 40, 50)<br>
</code>
</blockquote>
<code>print(myTuple[-2])</code><br>
<inputtype="text" id="input2_3_1" size="50" required><spanid="sp231" class="tick"></span><br>
<inputtype="button" onclick="myFunc2_3_1()" value="SUBMIT">
<br><br>
<code>print(myTuple[-4:-1])</code><br>
<inputtype="text" id="input2_3_2" size="50" required><spanid="sp232" class="tick"></span><br>
<inputtype="button" onclick="myFunc2_3_1()" value="SUBMIT">
<br><br>
<blockquote>
<code>
numTuple = (0, 10, 20, 30, 40, 50, 60, 70, 80)<br>
</code>
</blockquote>
<code>print(numTuple[2:5], numTuple[:4], numTuple[3:])</code><br>
<inputtype="text" id="input2_3_3" size="50" required><spanid="sp233" class="tick"></span><br>
<inputtype="button" onclick="myFunc2_3_1()" value="SUBMIT">
<br><br>
<divclass="divOutput" id="divOutput2_3_1" size="50"></div>
</ol>
</div>
<divclass="noprint">
<h2>Part 3: Coding</h2>
<h3>Narcissistic Number</h3>
<ul>
<li>What is <b>Narcissistic Number</b>?</li>
<li>Click <ahref='http://ey.westside66.org/32-math-minute-narcissistic-numbers/'>here</a> to learn more about <strong>Narcissistic Number</strong>!</li>
<li>A <strong>Narcissistic Number</strong> is a number that is the sum of its own digits each raised to the power of the number of digits.</li>
<li>How to determine if a number is a <strong>Narcissistic Number</strong>?</li>
<li>(Optional) Can you print all <strong>Narcissistic Number</strong> in the range of 1 to 999?</li>
</ul><br><br>
<divstyle="text-align: center;">
<imgsrc="resources/nar1.jpg" alt="" height="600" width="900" />
</div>
</div>
<divclass="noprint">
<h2>Part 4: File I/O</h2>
<h3>Alice's Adventures in Wonderland</h3>
<ul>
<li>Click <ahref='http://www.umich.edu/~umfandsf/other/ebooks/alice30.txt'>here</a> to download the text file to your local computer.</li>
<li>Write a program to count how many times the "<strong>March Hare</strong>" appears.</li>
<li>Generate a custom <strong>WordCloud</strong> image.</li>
</ul>
<divstyle="text-align: center;">
<imgsrc="resources/alice.png" alt="" height="450" width="600" />
</div>
</div>
<p><br/></p>
<div>
<p>
<!-- <a style="color:#999;font-weight:bold;" href="excutable.html">Link: make your .exe</a><hr /> -->
</p>
</div>
<p><br/><br/><br/></p>
<divid="footer" class="noprint">
<pclass="footer">
<inputtype=buttonvalue="Back" onClick="history.go(-1)">
<ahref="http://validator.w3.org/check?uri=referer">Valid XHTML 1.1</a>
| <ahref="http://jigsaw.w3.org/css-validator/">Valid CSS</a>
| Design by <ahref=""><b>Lucy Lin</b></a>
</p>
</div>
</div>
</div>
</body>
</html>