feat(curriculum): add python multiple choice questions (#38890)

This commit is contained in:
Kristofer Koishigawa
2020-05-28 22:40:36 +09:00
committed by GitHub
parent 18d2dca05b
commit 3567813c51
98 changed files with 1118 additions and 398 deletions

View File

@ -18,7 +18,7 @@ More resources:
```yml
question:
text: 'What will the following Python program print out?
text: 'What will the following Python program print out?:
<pre>def fred():<br> print("Zap")<br><br>def jane():<br> print("ABC")<br>
<br>
jane()<br>

View File

@ -18,7 +18,7 @@ More resources:
```yml
question:
text: 'Which does the same thing as the following code:
text: 'Which does the same thing as the following code?:
<pre>lst = []<br>for key, val in counts.items():<br> newtup = (val, key)<br> lst.append(newtup)<br><br>lst = sorted(lst, reverse=True)<br>print(lst)<pre>'
answers:
- 'print( sorted( [ (k,v) for k,v in counts.items() ] ) )'

View File

@ -18,7 +18,7 @@ More resources:
```yml
question:
text: "What will the following code print?
text: "What will the following code print?:
<pre>counts = { 'chuck' : 1 , 'annie' : 42, 'jan': 100}<br>
for key in counts:<br> if counts[key] > 10 :<br> print(key, counts[key])</pre>"
answers:

View File

@ -18,12 +18,12 @@ More resources:
```yml
question:
text: "What does the word 'continue' do in the middle of a loop."
text: "What does the word 'continue' do in the middle of a loop?"
answers:
- 'skips to the code directly after the loop'
- 'skips to the next line in the code'
- 'skips to the next iteration of the loop'
- 'skips the next block of code'
- 'Skips to the code directly after the loop.'
- 'Skips to the next line in the code.'
- 'Skips to the next iteration of the loop.'
- 'Skips the next block of code.'
solution: 3
```

View File

@ -17,7 +17,7 @@ videoId: hiRTRAqNlpE
```yml
question:
text: 'How many lines will the following code print?
text: 'How many lines will the following code print?:
<pre>for i in [2,1,5]:<br> print(i)</pre>'
answers:
- '1'

View File

@ -17,12 +17,12 @@ videoId: AelGAcoMXbI
```yml
question:
text: 'Below is code to find the smallest value from a list of values. One line has an error that will cause the code to not work as expected. Which line is it?
text: 'Below is code to find the smallest value from a list of values. One line has an error that will cause the code to not work as expected. Which line is it?:
<pre>
1|smallest = None<br>
2|print("Before:", smallest)<br>
3|for itervar in [3, 41, 12, 9, 74, 15]:<br>
4| if smallest is None or itervar smallest:<br>
4| if smallest is None or itervar < smallest:<br>
5| smallest = itervar<br>
6| break<br>
7| print("Loop:", itervar, smallest)<br>

View File

@ -17,7 +17,7 @@ videoId: dLA-szNRnUY
```yml
question:
text: 'What will the following code print out:
text: 'What will the following code print out?:
<pre>
n = 0<br>
while True:<br> if n == 3:<br> break<br> print(n)<br> n = n + 1</pre>'

View File

@ -17,15 +17,15 @@ videoId: 7lFM1T_CxBs
```yml
question:
text: "What will the output of the following code be like:
text: "What will the output of the following code be like?:
<pre>import urllib.request<br>
<br>
fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')<br>
for line in fhand:<br> print(line.decode().strip())</pre>"
answers:
- 'Just contents of "romeo.txt".'
- 'A header and the contents of "romeo.txt"'
- 'A header, a footer, and the contents of "romeo.txt"'
- 'A header and the contents of "romeo.txt".'
- 'A header, a footer, and the contents of "romeo.txt".'
solution: 1
```

View File

@ -20,7 +20,7 @@ More resources:
```yml
question:
text: 'What Python library is used for parsing HTML documents and extracting data from HTML documents.'
text: 'What Python library is used for parsing HTML documents and extracting data from HTML documents?'
answers:
- 'socket'
- 'http'

View File

@ -17,20 +17,30 @@ videoId: zjyT9DaAjx4
```yml
question:
text: "What does the following code create?
<pre>
import socket<br>
<br>
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>
mysock.connect(('data.pr4e.org', 80))<br>
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()<br>
mysock.send(cmd)<br>
<br>while True:<br> data = mysock.recv(512)<br> if len(data) < 1:<br> break<br> print(data.decode(),end='')<br><br>mysock.close()</pre>"
text: |
What does the following code create?:
```py
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if len(data) < 1:
break
print(data.decode(),end='')
mysock.close()
```
answers:
- 'simple web server'
- 'simple email client'
- 'simple todo list'
- 'simple web browser'
- 'A simple web server.'
- 'A simple email client.'
- 'A simple todo list.'
- 'A simple web browser.'
solution: 4
```

View File

@ -17,7 +17,7 @@ videoId: p1r3h_AMMIM
```yml
question:
text: "What will the following program print:
text: "What will the following program print?:
<pre>
class PartyAnimal:<br> x = 0<br> name = ''<br> def __init__(self, nam):<br> self.name = nam<br> print(self.name,'constructed')<br><br> def party(self):<br> self.x = self.x + 1<br> print(self.name,'party count',self.x)<br>
<br>

View File

@ -17,7 +17,7 @@ videoId: FiABKEuaSJ8
```yml
question:
text: 'What will the following program print:
text: 'What will the following program print?:
<pre>class PartyAnimal:<br> x = 0<br><br> def party(self) :<br> self.x = self.x + 2<br> print(self.x)<br>
<br>
an = PartyAnimal()<br>

View File

@ -17,7 +17,7 @@ videoId: dnzvfimrRMg
```yml
question:
text: 'What does dict equal after running this code?
text: 'What does dict equal after running this code?:
<pre>dict = {"Fri": 20, "Thu": 6, "Sat": 1}<br>
dict["Thu"] = 13<br>
dict["Sat"] = 2<br>

View File

@ -19,11 +19,11 @@ videoId: 3JGF-n3tDPU
question:
text: 'What is the purpose of the "def" keyword in Python?'
answers:
- 'It is slang that means "the following code is really cool"'
- 'It indicates the start of a function'
- 'It indicates that the following indented section of code is to be stored for later'
- 'b and c are both true'
- 'None of the above'
- 'It is slang that means "The following code is really cool."'
- 'It indicates the start of a function.'
- 'It indicates that the following indented section of code is to be stored for later.'
- 'b and c are both true.'
- 'None of the above.'
solution: 4
```

View File

@ -19,10 +19,10 @@ videoId: uJxGeTYy0us
question:
text: 'Which is NOT true about objects in Python?'
answers:
- 'Objects get created and used'
- 'Objects are bits of code and data'
- 'Objects hide detail'
- 'Objects are one of the five standard data types'
- 'Objects get created and used.'
- 'Objects are bits of code and data.'
- 'Objects hide detail.'
- 'Objects are one of the five standard data types.'
solution: 4
```

View File

@ -17,7 +17,7 @@ videoId: LaCZnTbQGkE
```yml
question:
text: "What will the following program print:
text: "What will the following program print?:
<pre>
import re<br>
s = 'A message from csev@umich.edu to cwen@iupui.edu about meeting @2PM'<br>

View File

@ -17,7 +17,7 @@ videoId: AqdfbrpkbHk
```yml
question:
text: 'What is the best practice for how many times a peice of string data should be stored in a database?'
text: 'What is the best practice for how many times a piece of string data should be stored in a database?'
answers:
- '0'
- '1'

View File

@ -17,7 +17,7 @@ videoId: QlNod5-kFpA
```yml
question:
text: 'Which is NOT a primary data structures in a database?'
text: 'Which is NOT a primary data structure in a database?'
answers:
- 'index'
- 'table'

View File

@ -17,7 +17,7 @@ videoId: LYZj207fKpQ
```yml
question:
text: 'What will the following code print?
text: 'What will the following code print?:
<pre>for n in "banana":<br> print(n)</pre>'
answers:
- 'n<br>n'

View File

@ -17,7 +17,7 @@ videoId: 3Lxpladfh2k
```yml
question:
text: "What will the following code print?
text: "What will the following code print?:
<pre>d = dict()<br>d['quincy'] = 1<br>d['beau'] = 5<br>d['kris'] = 9<br>for (k,i) in d.items():<br> print(k, i)</pre>"
answers:
- 'k i<br>k i<br>k i'

View File

@ -20,7 +20,7 @@ question:
text: 'What does API stand for?'
answers:
- 'Application Portable Intelligence'
- 'Accociate Programming International'
- 'Associate Programming International'
- 'Application Program Interface'
- 'Action Portable Interface'
solution: 3

View File

@ -17,7 +17,7 @@ videoId: ZJE-U56BppM
```yml
question:
text: "What will the following code print?
text: "What will the following code print?:
<pre>import json<br>
<br>
data = '''<br>[<br> { 'id' : '001',<br> 'x' : '2',<br> 'name' : 'Quincy'<br> } ,<br> { 'id' : '009',<br> 'x' : '7',<br> 'name' : 'Mrugesh'<br> }<br>]'''<br>

View File

@ -17,7 +17,7 @@ videoId: muerlsCHExI
```yml
question:
text: 'With a services oriented approach to developing web apps, where is the data located.'
text: 'With a services oriented approach to developing web apps, where is the data located?'
answers:
- 'Spread across many computer systems connected via the internet or internal network.'
- 'Within different services on the main web server.'

View File

@ -17,7 +17,7 @@ videoId: _pZ0srbg7So
```yml
question:
text: 'What is wrong with the following XML?
text: 'What is wrong with the following XML?:
<pre>&ltperson&gt<br>
&ltname>Chuck&lt/name><br>
&ltphone type="intl"><br> +1 734 303 4456<br>