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

@ -26,7 +26,7 @@
],
[
"5ea9997bbec2e9bc47e94db2",
"Developing and Nmap Scanner part 2"
"Developing an Nmap Scanner part 2"
],
[
"5ea9997bbec2e9bc47e94db3",

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>

View File

@ -15,7 +15,8 @@ videoId: mHjxzFS5_Z0
```yml
question:
text: 'When using Matplotlib''s global API, what does the order of numbers mean here <pre>plt.subplot(1, 2, 1)</pre>'
text: |
When using Matplotlib's global API, what does the order of numbers mean here?: `plt.subplot(1, 2, 1)`
answers:
- 'My figure will have one column, two rows, and I am going to start drawing in the first (left) plot.'
- 'I am going to start drawing in the first (left) plot, my figure will have two rows, and my figure will have one column.'

View File

@ -15,7 +15,8 @@ videoId: kj7QqjXhH6A
```yml
question:
text: 'The Python method <code>.duplicated()</code> returns a boolean Series for your DataFrame. <code>True</code> is the return value for rows that:'
text: |
The Python method `.duplicated()` returns a boolean Series for your DataFrame. `True` is the return value for rows that:
answers:
- contain a duplicate, where the value for the row contains the first occurrence of that value.
- contain a duplicate, where the value for the row is at least the second occurrence of that value.

View File

@ -15,12 +15,39 @@ videoId: ovYNhnltVxY
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
import numpy as np
s = pd.Series(['a', 3, np.nan, 1, np.nan])
print(s.notnull().sum())
```
answers:
- one
- two
- three
solution: 3
- '3'
- |
```
0 True
1 True
2 False
3 True
4 False
dtype: bool
```
- |
```
0 False
1 False
2 True
3 False
4 True
dtype: bool
```
solution: 1
```
</section>

View File

@ -15,12 +15,48 @@ videoId: sTMN_pdI6S0
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
import numpy as np
s = pd.Series([np.nan, 1, 2, np.nan, 3])
s = s.fillna(method='ffill')
print(s)
```
answers:
- one
- two
- three
solution: 3
- |
```
0 1.0
1 1.0
2 2.0
3 3.0
4 3.0
dtype: float64
```
- |
```
0 NaN
1 1.0
2 2.0
3 2.0
4 3.0
dtype: float64
```
- |
```
0 NaN
1 1.0
2 2.0
3 NaN
4 3.0
dtype: float64
```
solution: 2
```
</section>

View File

@ -15,11 +15,11 @@ videoId: h8caJq2Bb9w
```yml
question:
text: Question
text: What is *not* allowed in a Jupyter Notebook's cell?
answers:
- one
- two
- three
- "Markdown"
- "Python code"
- "An Excel sheet"
solution: 3
```

View File

@ -15,12 +15,13 @@ videoId: VJrP2FUzKP0
```yml
question:
text: Question
text: "Why should you choose R over Python for data analysis?"
answers:
- one
- two
- three
solution: 3
- "It's simple to learn."
- "It's better at dealing with advanced statistical methods."
- "There are many powerful libraries that support R."
- "It's free and open source."
solution: 2
```
</section>

View File

@ -15,12 +15,14 @@ videoId: k1msxD3JIxE
```yml
question:
text: Question
text: "What kind of data can you import and work with in a Jupyter Notebook?"
answers:
- one
- two
- three
solution: 3
- "Excel files."
- "CSV files."
- "XML files."
- "Data from an API."
- "All of the above."
solution: 5
```
</section>

View File

@ -15,11 +15,33 @@ videoId: VDYVFHBL1AM
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
A = np.array([
['a', 'b', 'c'],
['d', 'e', 'f'],
['g', 'h', 'i']
])
print(A[:, :2])
```
answers:
- one
- two
- three
- "[['a' 'b']]"
- |
```
[['b' 'c']
['e' 'f']
['h' 'i']]
```
- |
```
[['a' 'b']
['d' 'e']
['g' 'h']]
```
solution: 3
```

View File

@ -15,12 +15,20 @@ videoId: N1ttsMmcVMM
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
a = np.arange(5)
print(a <= 3)
```
answers:
- one
- two
- three
solution: 3
- "[False, False, False, False, True]"
- "[5]"
- "[0, 1, 2, 3]"
- "[True, True, True, True, False]"
solution: 4
```
</section>

View File

@ -15,12 +15,12 @@ videoId: P-JjV6GBCmk
```yml
question:
text: Question
text: "Why is Numpy an important, but unpopular Python library?"
answers:
- one
- two
- three
solution: 3
- "Often you won't work directly with Numpy."
- "It's is extremely slow."
- "Working with Numpy is difficult."
solution: 1
```
</section>

View File

@ -15,12 +15,14 @@ videoId: YIqgrNLAZkA
```yml
question:
text: Question
text: |
About how much memory does the integer `5` consume in plain Python?
answers:
- one
- two
- three
solution: 3
- 32 bits
- 20 bytes
- 16 bytes
- 8 bits
solution: 2
```
</section>

View File

@ -15,12 +15,19 @@ videoId: eqSVcJbaPdk
```yml
question:
text: Question
text: |
What is the value of `a` after you run the following code?:
```py
a = np.arange(5)
a + 20
```
answers:
- one
- two
- three
solution: 3
- "[20, 21, 22, 24, 24]"
- "[0, 1, 2, 3, 4, 5]"
- "[25, 26, 27, 28, 29]"
solution: 2
```
</section>

View File

@ -15,12 +15,51 @@ videoId: BFlH0fN5xRQ
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.DataFrame({
'Certificates': [8, 2, 5, 6],
'Time (in months)': [16, 5, 9, 12]
})
names = ['Tom', 'Kris', 'Ahmad', 'Beau']
certificates_earned.index = names
longest_streak = pd.Series([13, 11, 9, 7], index=names)
certificates_earned['Longest streak'] = longest_streak
print(certificates_earned)
```
answers:
- one
- two
- three
solution: 3
- |
```
Tom 13
Kris 11
Ahmad 9
Beau 7
Name: Longest streak, dtype: int64
```
- |
```
Certificates Time (in months) Longest streak
Tom 8 16 13
Kris 2 5 11
Ahmad 5 9 9
Beau 6 12 7
```
- |
```
Certificates Longest streak
Tom 8 13
Kris 2 11
Ahmad 5 9
Beau 6 7
```
solution: 2
```
</section>

View File

@ -15,11 +15,37 @@ videoId: _sSo2XZoB3E
```yml
question:
text: Question
text: |
What code would add a "Certificates per month" column to the `certificates_earned` DataFrame like the one below?:
```
Certificates Time (in months) Certificates per month
Tom 8 16 0.50
Kris 2 5 0.40
Ahmad 5 9 0.56
Beau 6 12 0.50
```
answers:
- one
- two
- three
- |
```py
certificates_earned['Certificates'] /
certificates_earned['Time (in months)']
```
- |
```py
certificates_earned['Certificates per month'] = round(
certificates_earned['Certificates'] /
certificates_earned['Time (in months)']
)
```
- |
```py
certificates_earned['Certificates per month'] = round(
certificates_earned['Certificates'] /
certificates_earned['Time (in months)'], 2
)
```
solution: 3
```

View File

@ -15,11 +15,43 @@ videoId: 7SgFBYXaiH0
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.DataFrame({
'Certificates': [8, 2, 5, 6],
'Time (in months)': [16, 5, 9, 12]
})
certificates_earned.index = ['Tom', 'Kris', 'Ahmad', 'Beau']
print(certificates_earned.iloc[2])
```
answers:
- one
- two
- three
- |
```
Tom 16
Kris 5
Ahmad 9
Beau 12
Name: Time (in months), dtype: int64
```
- |
```
Certificates 6
Time (in months) 12
Name: Beau, dtype: int64
```
- |
```
Certificates 5
Time (in months) 9
Name: Ahmad, dtype: int64
```
solution: 3
```

View File

@ -15,11 +15,42 @@ videoId: -ZOrgV_aA9A
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.Series(
[8, 2, 5, 6],
index=['Tom', 'Kris', 'Ahmad', 'Beau']
)
print(certificates_earned[certificates_earned > 5])
```
answers:
- one
- two
- three
- |
```
Tom True
Kris False
Ahmad False
Beau True
dtype: int64
```
- |
```
Tom 8
Ahmad 5
Beau 6
dtype: int64
```
- |
```
Tom 8
Beau 6
dtype: int64
```
solution: 3
```

View File

@ -15,12 +15,46 @@ videoId: 0xACW-8cZU0
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.Series(
[8, 2, 5, 6],
index=['Tom', 'Kris', 'Ahmad', 'Beau']
)
print(certificates_earned)
```
answers:
- one
- two
- three
solution: 3
- |
```
Tom 8
Kris 2
Ahmad 5
Beau 6
dtype: int64
```
- |
```
Kris 2
Ahmad 5
Beau 6
Tom 8
dtype: int64
```
- |
```
Tom 8
Kris 2
Ahmad 5
Beau 6
Name: certificates_earned dtype: int64
```
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: NzpU17ZVlUw
```yml
question:
text: Question
text: What is the main difference between lists and tuples in Python?
answers:
- one
- two
- three
solution: 3
- Tuples are immutable.
- Lists are ordered.
- Tuples are unordered.
solution: 1
```
</section>

View File

@ -17,9 +17,9 @@ videoId: MtgXS1MofRw
question:
text: What method does a <code>Cursor</code> instance have and what does it allow?
answers:
- The <code>Cursor</code> instance has a <code>.Run()</code> method which allows you to run SQL queries.
- The <code>Cursor</code> instance has a <code>.Select()</code> method which allows you to select records.
- The <code>Cursor</code> instance has a <code>.Execute()</code> method which will receive SQL parameters to run against the database.
- The <code>Cursor</code> instance has a <code>.run()</code> method which allows you to run SQL queries.
- The <code>Cursor</code> instance has a <code>.select()</code> method which allows you to select records.
- The <code>Cursor</code> instance has an <code>.execute()</code> method which will receive SQL parameters to run against the database.
solution: 3
```

View File

@ -15,12 +15,35 @@ videoId: cDnt02BcHng
```yml
question:
text: Question
text: |
Given a file named `certificates.csv` with these contents:
```
Name$Certificates$Time (in months)
Tom$8$16
Kris$2$5
Ahmad$5$9
Beau$6$12
```
Fill in the blanks for the missing arguments below:
```py
import csv
with open(___, 'r') as fp:
reader = csv.reader(fp, delimiter=___)
next(reader)
for index, values in enumerate(reader):
name, certs_num, months_num = values
print(f"{name} earned {___} certificates in {months_num} months")
```
answers:
- one
- two
- three
solution: 3
- <code>'certificates.csv', '-', values</code>
- <code>'certificates.csv', '$', certs_num</code>
- <code>'certificates', '$', certs_num</code>
solution: 2
```
</section>

View File

@ -15,11 +15,25 @@ videoId: v-7Y7koJ_N0
```yml
question:
text: Question
text: |
What code would change the values in the 3rd column of both of the following Numpy arrays to 20?:
```py
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
# Output:
# [[ 1 2 3 4 5]
# [ 6 7 20 9 10]]
```
answers:
- one
- two
- three
- |
`a[:, 3] = 20`
- |
`a[2, :] = 20`
- |
`a[:, 2] = 20`
- |
`a[1, 2] = 20`
solution: 3
```

View File

@ -15,7 +15,7 @@ videoId: f9QrZrKQMLI
```yml
question:
text: 'What will the following code print:<pre>b = np.array([[1.0,2.0,3.0],[3.0,4.0,5.0]])<br>print(b)</pre>'
text: 'What will the following code print?:<pre>b = np.array([[1.0,2.0,3.0],[3.0,4.0,5.0]])<br>print(b)</pre>'
answers:
- '<pre>[[1.0 2.0 3.0]<br>[3.0 4.0 5.0]]<pre>'
- '<pre>[[1. 2. 3.]<br>[3. 4. 5.]]<pre>'

View File

@ -15,12 +15,25 @@ videoId: iIoQ0_L0GvA
```yml
question:
text: Question
text: |
What is the value of `a` after running the following code?:
```py
import numpy as np
a = np.array([1, 2, 3, 4, 5])
b = a
b[2] = 20
```
answers:
- one
- two
- three
solution: 3
- |
`[1, 2, 3, 4, 5]`
- |
`[1, 2, 20, 4, 5]`
- |
`[1, 20, 3, 4, 5]`
solution: 2
```
</section>

View File

@ -15,12 +15,46 @@ videoId: 0jGfH8BPfOk
```yml
question:
text: Question
text: |
What is another way to produce the following array?:
```
[[1. 1. 1. 1. 1.]
[1. 0. 0. 0. 1.]
[1. 0. 9. 0. 1.]
[1. 0. 0. 0. 1.]
[1. 1. 1. 1. 1.]]
```
answers:
- one
- two
- three
solution: 3
- |
```py
output = np.ones((5, 5))
z = np.zeros((3, 3))
z[1, 1] = 9
output[1:-1, 1:-1] = z
```
- |
```py
output = np.ones((5, 5))
z = np.zeros((3, 3))
z[1, 1] = 9
output[1:3, 1:3] = z
```
- |
```py
output = np.ones((5, 5))
z = np.zeros((3, 3))
z[1, 1] = 9
output[4:1, 4:1] = z
```
solution: 1
```
</section>

View File

@ -15,12 +15,30 @@ videoId: CEykdsKT4U4
```yml
question:
text: Question
text: |
What will the following code print?:
```py
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
print(np.full_like(a, 100))
```
answers:
- one
- two
- three
solution: 3
- |
```
[[100 100 100 100 100]]
```
- |
```
[[100 100 100 100 100]
[100 100 100 100 100]]
```
- |
```
[[ 1 2 3 4 5]
[ 6 7 20 9 10]]
```
solution: 2
```
</section>

View File

@ -15,11 +15,42 @@ videoId: tUdBZ7pF8Jg
```yml
question:
text: Question
text: |
Given a file named `data.txt` with these contents:
```
29,97,32,100,45
15,88,5,75,22
```
What code would produce the following array?:
```py
[29. 32. 45. 15. 5. 22.]
```
answers:
- one
- two
- three
- |
```
filedata = np.genfromtxt('data.txt', delimiter=',')
output = np.any(filedata < 50)
print(output)
```
- |
```
filedata = np.genfromtxt('data.txt', delimiter=',')
output = np.all(filedata < 50, axis=1)
print(output)
```
- |
```
filedata = np.genfromtxt('data.txt', delimiter=',')
output = filedata[filedata < 50]
print(output)
```
solution: 3
```

View File

@ -15,12 +15,22 @@ videoId: 7txegvyhtVk
```yml
question:
text: Question
text: |
What is the value of `b` after running the following code?:
```py
import numpy as np
a = np.array(([1, 2, 3, 4, 5], [6, 7, 8, 9, 10]))
b = np.max(a, axis=1).sum()
```
answers:
- one
- two
- three
solution: 3
- '10'
- '7'
- '5'
- '15'
solution: 4
```
</section>

View File

@ -15,12 +15,35 @@ videoId: VNWAQbEM-C8
```yml
question:
text: Question
text: |
What code would produce the following array?:
```
[[1. 1.]
[1. 1.]
[1. 1.]
[1. 1.]]
```
answers:
- one
- two
- three
solution: 3
- |
```py
a = np.ones((2, 4))
b = a.reshape((4, 2))
print(b)
```
- |
```py
a = np.ones((2, 4))
b = a.reshape((2, 4))
print(b)
```
- |
```py
a = np.ones((2, 4))
b = a.reshape((8, 1))
print(b)
```
solution: 1
```
</section>

View File

@ -15,12 +15,13 @@ videoId: 5Nwfs5Ej85Q
```yml
question:
text: Question
text: 'Why are Numpy arrays faster than regular Python lists?:'
answers:
- one
- two
- three
solution: 3
- Numpy does not perform type checking while iterating through objects.
- Numpy uses fixed types.
- Numpy uses contiguous memory.
- All of the above.
solution: 4
```
</section>

View File

@ -15,12 +15,17 @@ videoId: ugYfJNTawks
```yml
question:
text: Question
text: |
Which socket object method lets you set the maximum amount of data your client accepts at once?
answers:
- one
- two
- three
solution: 3
- |
`.recv(1024)`
- |
`.decode('ascii')`
- |
`.connect(host, port)`
solution: 1
```
</section>

View File

@ -15,11 +15,23 @@ videoId: CeGW761BIsA
```yml
question:
text: Question
text: |
Fill in the blanks to complete the `banner` function below:
```py
def banner(ip, port):
s = socket.socket()
s.____((ip, ____))
print(s.recv(1024))
```
answers:
- one
- two
- three
- |
`connect`, `port`
- |
`getsockname`, `'1-1024'`
- |
`connect`, `int(port)`
solution: 3
```

View File

@ -15,11 +15,15 @@ videoId: z_qkqZS7KZ4
```yml
question:
text: Question
text: |
What is the main difference between the `.connect()` and `.connect_ex()` methods?
answers:
- one
- two
- three
- There is no difference between the two methods.
- |
If there is an error or if no host is found, `.connect()` returns an error code while `.connect_ex()` raises an exception.
- |
If there is an error or if no host is found, `.connect()` raises an exception while `.connect_ex()` returns an error code.
solution: 3
```

View File

@ -15,11 +15,16 @@ videoId: jYk9XaGoAnk
```yml
question:
text: Question
text: |
What is the correct command to install the Python 3 version of the `python-nmap` library?
answers:
- one
- two
- three
- |
`sudo apt install python-nmap`
- |
`pip install python-nmap`
- |
`pip3 install python-nmap`
solution: 3
```

View File

@ -0,0 +1,32 @@
---
id: 5ea9997bbec2e9bc47e94db2
title: Developing an Nmap Scanner part 2
challengeType: 11
isHidden: true
videoId: a98PscnUsTg
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
```yml
question:
text: |
Which of the following allows you to scan for UDP ports between 21 to 443?
answers:
- |
`.scan(ip_addr, '21-443', '-v -sU')`
- |
`.scan(ip_addr, '1-1024', '-v -sS')`
- |
`.scan(ip_addr, '21-443', '-v -sS')`
solution: 1
```
</section>

View File

@ -1,27 +0,0 @@
---
id: 5ea9997bbec2e9bc47e94db2
title: Developing and Nmap Scanner part 2
challengeType: 11
isHidden: true
videoId: a98PscnUsTg
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
```yml
question:
text: Question
answers:
- one
- two
- three
solution: 3
```
</section>

View File

@ -15,12 +15,14 @@ videoId: XeQ7ZKtb998
```yml
question:
text: Question
text: |
What code editor and extension does the instructor recommend for developing penetration testing tools in Python?
answers:
- one
- two
- three
solution: 3
- Atom and the atom-python-run extension.
- VSCode and Microsoft's Python extension.
- Sublime Text and the Anaconda package.
solution: 2
```
</section>

View File

@ -15,11 +15,16 @@ videoId: F1QI9tNuDQg
```yml
question:
text: Question
text: |
Which of the following functions creates a socket object?
answers:
- one
- two
- three
- |
`socket.bind((host, port))`
- |
`socket.gethostbyname()`
- |
`socket.socket(socket.AF_INET, socket.SOCK_STREAM)`
solution: 3
```

View File

@ -15,12 +15,14 @@ videoId: bejQ-W9BGJg
```yml
question:
text: Question
text: How should you assign weights to input neurons before training your network for the first time?
answers:
- one
- two
- three
solution: 3
- From smallest to largest.
- Completely randomly.
- Alphabetically.
- None of the above.
solution: 2
```
</section>

View File

@ -15,12 +15,13 @@ videoId: Y5M7KH4A4n4
```yml
question:
text: Question
text: When are Convolutional Neural Networks not useful?
answers:
- one
- two
- three
solution: 3
- If your data can't be made to look like an image, or if you can rearrange elements of your data and it's still just as useful.
- If your data is made up of different 2D or 3D images.
- If your data is text or sound based.
solution: 1
```
</section>

View File

@ -15,12 +15,13 @@ videoId: zvalnHWGtx4
```yml
question:
text: Question
text: Why is it better to calculate the gradient (slope) directly rather than numerically?
answers:
- one
- two
- three
solution: 3
- It is computationally expensive to go back through the entire neural network and adjust the weights for each layer of the neural network.
- It is more accurate.
- There is no difference between the two methods.
solution: 1
```
</section>

View File

@ -15,11 +15,13 @@ videoId: UVimlsy9eW0
```yml
question:
text: Question
text: |
What are the main neural network components that make up a Long Short Term Memory network?
answers:
- one
- two
- three
- New information and prediction.
- Prediction, collected possibilities, and selection.
- Prediction, ignoring, forgetting, and selection.
solution: 3
```

View File

@ -15,12 +15,13 @@ videoId: LMNub5frQi4
```yml
question:
text: Question
text: |
Most people that are experts in AI or machine learning usually...:
answers:
- one
- two
- three
solution: 3
- have one specialization.
- have many specializations.
- have a deep understanding of many different frameworks.
solution: 1
```
</section>

View File

@ -15,11 +15,11 @@ videoId: eCATNvwraXg
```yml
question:
text: Question
text: What is **not** a good way to increase the accuracy of a convolutional neural network?
answers:
- one
- two
- three
- Augmenting the data you already have.
- Using a pre-trained model.
- Using your test data to retrain the model.
solution: 3
```

View File

@ -15,12 +15,36 @@ videoId: h1XUt1AgIOI
```yml
question:
text: Question
text: |
Fill in the blanks below to use Google's pre-trained MobileNet V2 model as a base for a convolutional neural network:
```py
base_model = tf.__A__.applications.__B__(input_shape=(160, 160, 3),
include_top=__C__,
weights='imagenet'
)
```
answers:
- one
- two
- three
solution: 3
- |
A: `keras`
B: `MobileNetV2`
C: `False`
- |
A: `Keras`
B: `MobileNetV2`
C: `True`
- |
A: `keras`
B: `mobile_net_v2`
C: `False`
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: LrdmcQpTyLw
```yml
question:
text: Question
text: What are the three main properties of each convolutional layer?
answers:
- one
- two
- three
solution: 3
- Input size, the number of filters, and the sample size of the filters.
- Input size, input dimensions, and the color values of the input.
- Input size, input padding, and stride.
solution: 1
```
</section>

View File

@ -15,11 +15,12 @@ videoId: _1kTP7uoU9E
```yml
question:
text: Question
text: |
Dense neural networks analyze input on a global scale and recognize patterns in specific areas. Convolutional neural networks...:
answers:
- one
- two
- three
- also analyze input globally and extract features from specific areas.
- do not work well for image classification or object detection.
- scan through the entire input a little at a time and learn local patterns.
solution: 3
```

View File

@ -15,12 +15,15 @@ videoId: 5wHw8BTd2ZQ
```yml
question:
text: Question
text: What kind of estimator/model does TensorFlow recommend using for classification?
answers:
- one
- two
- three
solution: 3
- |
`LinearClassifier`
- |
`DNNClassifier`
- |
`BoostedTreesClassifier`
solution: 2
```
</section>

View File

@ -15,12 +15,12 @@ videoId: qFF7ZQNvK9E
```yml
question:
text: Question
text: What is classification?
answers:
- one
- two
- three
solution: 3
- The process of separating data points into different classes.
- Predicting a numeric value or forecast based on independent and dependent variables.
- None of the above.
solution: 1
```
</section>

View File

@ -15,12 +15,14 @@ videoId: 8sqIaHc9Cz4
```yml
question:
text: Question
text: Which of the following steps is **not** part of the K-Means algorithm?
answers:
- one
- two
- three
solution: 3
- Randomly pick K points to place K centeroids.
- Assign each K point to the closest K centeroid.
- Move each K centeroid into the middle of all of their data points.
- Shuffle the K points so they're redistributed randomly.
- Reassign each K point to the closest K centeroid.
solution: 4
```
</section>

View File

@ -15,12 +15,12 @@ videoId: IZg24y4wEPY
```yml
question:
text: Question
text: What makes a Hidden Markov model different than linear regression or classification?
answers:
- one
- two
- three
solution: 3
- It uses probability distributions to predict future events or states.
- It analyzes the relationship between independent and dependent variables to make predictions.
- It separates data points into separate categories.
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: _cEwvqVoBhI
```yml
question:
text: Question
text: What are epochs?
answers:
- one
- two
- three
solution: 3
- The number of times the model will see the same data.
- A type of graph.
- The number of elements you feed to the model at once.
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: wz9J1slsi7I
```yml
question:
text: Question
text: What is categorical data?
answers:
- one
- two
- three
solution: 3
- Another term for one-hot encoding.
- Any data that is not numeric.
- Any data that is represented numerically.
solution: 2
```
</section>

View File

@ -15,11 +15,14 @@ videoId: fYAYvLUawnc
```yml
question:
text: Question
text: What TensorFlow module should you import to implement `.HiddenMarkovModel()`?
answers:
- one
- two
- three
- |
`tensorflow.keras`
- |
`tensorflow_gpu`
- |
`tensorflow_probability`
solution: 3
```

View File

@ -15,11 +15,12 @@ videoId: u85IOSsJsPI
```yml
question:
text: Question
text: |
What does the pandas `.head()` function do?
answers:
- one
- two
- three
- Returns the number of entries in a data frame.
- Returns the number of columns in a data frame.
- By default, shows the first five rows or entries in a data frame.
solution: 3
```

View File

@ -15,12 +15,16 @@ videoId: u5lZURgcWnU
```yml
question:
text: Question
text: |
Which type of analysis would be best suited for the following problem?:
You have the average temperature in the month of March for the last 100 years. Using this data, you want to predict the average temperature in the month of March 5 years from now.
answers:
- one
- two
- three
solution: 3
- Multiple regression
- Correlation
- Decision tree
- Linear regression
solution: 4
```
</section>

View File

@ -15,11 +15,38 @@ videoId: kfv0K8MtkIc
```yml
question:
text: Question
text: |
Fill in the blanks below to complete the architechture for a convolutional neural network:
```py
model = models.__A__()
model.add(layers.__B__(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.__C__(2, 2))
model.add(layers.__B__(64, (3, 3), activation='relu'))
model.add(layers.__C__(2, 2))
model.add(layers.__B__(32, (3, 3), activation='relu'))
model.add(layers.__C__(2, 2))
```
answers:
- one
- two
- three
- |
A: `Sequential`
B: `add`
C: `Wrapper`
- |
A: `keras`
B: `Cropping2D`
C: `AlphaDropout`
- |
A: `Sequential`
B: `Conv2D`
C: `MaxPooling2D`
solution: 3
```

View File

@ -15,12 +15,13 @@ videoId: KwL1qTR5MT8
```yml
question:
text: Question
text: |
Which statement below is **false**?
answers:
- one
- two
- three
solution: 3
- Neural networks are modeled after the way the human brain works.
- Computer programs that play tic-tac-toe or chess against human players are examples of simple artificial intelligence.
- Machine learning is a subset of artificial intelligence.
solution: 1
```
</section>

View File

@ -15,12 +15,14 @@ videoId: r9hRyGGjOgQ
```yml
question:
text: Question
text: Which of the following is **not** a type of tensor?
answers:
- one
- two
- three
solution: 3
- Variable
- Flowing
- Placeholder
- SparseTensor
- Constant
solution: 2
```
</section>

View File

@ -15,11 +15,48 @@ videoId: 32WBFS7lfsw
```yml
question:
text: Question
text: |
Fill in the blanks below to complete the `build_model` function:
```py
def build_mode(vocab_size, embedding_dim, rnn_units, batch_size):
model = tf.keras.Sequential([
tf.keras.layers.Embedding(vocab_size,
embedding_dim,
batch_input_shape=[batch_size, None]),
tf.keras.layers.__A__(rnn_units,
return_sequences=__B__,
recurrent_initializer='glorot_uniform),
tf.keras.layers.Dense(__C__)
])
__D__
```
answers:
- one
- two
- three
- |
A: `ELU`
B: `True`
C: `vocab_size`
D: `return model`
- |
A: `LSTM`
B: `False`
C: `batch_size`
D: `return model`
- |
A: `LSTM`
B: `True`
C: `vocab_size`
D: `return model`
solution: 3
```

View File

@ -15,12 +15,28 @@ videoId: j5xsxjq_Xk8
```yml
question:
text: Question
text: |
Fill in the blanks below to create the training examples for the RNN:
```py
char_dataset = tf.data.__A__.__B__(text_as_int)
```
answers:
- one
- two
- three
solution: 3
- |
A: `DataSet`
B: `from_tensor_slices`
- |
A: `data`
B: `from_tensors`
- |
A: `DataSet`
B: `from_generator`
solution: 1
```
</section>

View File

@ -15,12 +15,13 @@ videoId: WO1hINnBj20
```yml
question:
text: Question
text: |
Before you make a prediction with your own review, you should...:
answers:
- one
- two
- three
solution: 3
- decode the training dataset and compare the results to the test data.
- use the encodings from the training dataset to encode your review.
- assign random values between 0 and the maximum number of vocabulary in your dataset to each word in your review.
solution: 2
```
</section>

View File

@ -15,11 +15,12 @@ videoId: mUU9YXOFbZg
```yml
question:
text: Question
text: |
Word embeddings are...:
answers:
- one
- two
- three
- an unordered group of encoded words that describes the frequency of words in a given document.
- a group of encoded words that preserves the original order of the words in a given document.
- a vectorized representation of words in a given document that places words with similar meanings near each other.
solution: 3
```

View File

@ -15,12 +15,17 @@ videoId: bX5681NPOcA
```yml
question:
text: Question
text: What is true about Recurrent Neural Networks?
answers:
- one
- two
- three
solution: 3
- |
1: They are a type of feed-forward neural network.
- |
2: They maintain an internal memory/state of the input that was already processed.
- |
3: RNN's contain a loop and process one piece of input at a time.
- |
4: Both 2 and 3.
solution: 4
```
</section>

View File

@ -15,11 +15,36 @@ videoId: lYeLtu8Nq7c
```yml
question:
text: Question
text: |
Fill in the blanks below to create the model for the RNN:
```py
model = __A__.keras.Sequential([
__A__.keras.layers.__B__(88584, 32),
__A__.keras.layers.__C__(32),
__A__.keras.layers.DENSE(1, activation='sigmoid')
])
```
answers:
- one
- two
- three
- |
A: `tensor_flow`
B: `embedding`
C: `LSTM`
- |
A: `tf`
B: `Embedding`
C: `AlphaDropout`
- |
A: `tf`
B: `Embedding`
C: `LSTM`
solution: 3
```

View File

@ -15,12 +15,41 @@ videoId: hEUiK7j9UI8
```yml
question:
text: Question
text: |
Fill in the blanks below to save your model's checkpoints in the `./checkpoints` directory and call the latest checkpoint for training:
```py
checkpoint_dir = __A__
checkpoint_prefix = os.path.join(checkpoint_dir, 'ckpt_{epoch}')
checkpoint_callback = tf.keras.callbacks.__B__(
filepath=checkpoint_prefix,
save_weights_only=True
)
history = model.fit(data, epochs=2, callbacks=[__C__])
```
answers:
- one
- two
- three
solution: 3
- |
A: `'./training_checkpoints'`
B: `ModelCheckpoint`
C: `checkpoint_prefix`
- |
A: `'./checkpoints'`
B: `ModelCheckpoint`
C: `checkpoint_callback`
- |
A: `'./checkpoints'`
B: `BaseLogger`
C: `checkpoint_callback`
solution: 2
```
</section>

View File

@ -15,12 +15,13 @@ videoId: ZyCaF5S-lKg
```yml
question:
text: Question
text: |
Natural Language Processing is a branch of artifitial intelligence that...:
answers:
- one
- two
- three
solution: 3
- deals with how computers understand and process natural/human languages.
- translates image data into natural/human languages.
- is focused on translating computer languages into natural/human languages.
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: S45tqW6BqRs
```yml
question:
text: Question
text: Which activation function switches values between -1 and 1?
answers:
- one
- two
- three
solution: 3
- Relu (Rectified Linear Unit)
- Tanh (Hyperbolic Tangent)
- Sigmoid
solution: 2
```
</section>

View File

@ -15,12 +15,37 @@ videoId: K8bz1bmOCTw
```yml
question:
text: Question
text: |
Fill in the blanks below to build a sequential model of dense layers:
```py
model = __A__.__B__([
__A__.layers.Flatten(input_shape=(28, 28)),
__A__.layers.__C__(128, activation='relu'),
__A__.layers.__C__(10, activation='softmax')
])
```
answers:
- one
- two
- three
solution: 3
- |
A: `keras`
B: `Sequential`
C: `Dense`
- |
A: `tf`
B: `Sequential`
C: `Categorical`
- |
A: `keras`
B: `sequential`
C: `dense`
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: hdOtRPQe1o4
```yml
question:
text: Question
text: What is an optimizer function?
answers:
- one
- two
- three
solution: 3
- A function that increases the accuracy of a model's predictions.
- A function that implements the gradient descent and backpropogation algorithms for you.
- A function that reduces the time a model needs to train.
solution: 2
```
</section>

View File

@ -15,11 +15,12 @@ videoId: uisdfrNrZW4
```yml
question:
text: Question
text: |
A densely connected neural network is one in which...:
answers:
- one
- two
- three
- all the neurons in the current layer are connected to one neuron in the previous layer.
- all the neurons in each layer are connected randomly.
- all the neurons in the current layer are connected to every neuron in the previous layer.
solution: 3
```

View File

@ -15,12 +15,33 @@ videoId: RBBSNta234s
```yml
question:
text: Question
text: |
Fill in the blanks to complete the following Q-Learning equation:
```py
Q[__A__, __B__] = Q[__A__, __B__] + LEARNING_RATE * (reward + GAMMA * np.max(Q[__C__, :]) - Q[__A__, __B__])
```
answers:
- one
- two
- three
solution: 3
- |
A: `state`
B: `action`
C: `next_state`
- |
A: `state`
B: `action`
C: `prev_state`
- |
A: `state`
B: `reaction`
C: `next_state`
solution: 1
```
</section>

View File

@ -15,12 +15,11 @@ videoId: DX7hJuaUZ7o
```yml
question:
text: Question
text: What can happen if the agent does not have a good balance of taking random actions and using learned actions?
answers:
- one
- two
- three
solution: 3
- The agent will always try to minimize its reward for the current state/action, leading to local minima.
- The agent will always try to maximize its reward for the current state/action, leading to local maxima.
solution: 2
```
</section>

View File

@ -15,12 +15,12 @@ videoId: Cf7DSU0gVb4
```yml
question:
text: Question
text: The key components of reinforcement learning are...
answers:
- one
- two
- three
solution: 3
- environment, representative, state, reaction, and reward.
- environment, agent, state, action, and reward.
- habitat, agent, state, action, and punishment.
solution: 2
```
</section>