python for data science ai & development coursera week 5 quiz answers
Practice Quiz
1. What does API stand for?
- Application Programming Interaction
- Automatic Program Interaction
- Application Process Interface
- Application Programming Interface
2. The chart used to plot the cryptocurrency data in the lab is a
- Line Chart
- Point and Figure Chart
- Pole Chart
- Candlestick Chart
3. What information are we trying to find for each day in the lab for the chart?
- Open (Last), High (Max), Low (Min), Close (First)
- Open (First), High (Max), Low (Min), Close (Last)
- Open (Max), High (First), Low (Last), Close (Min)
- Open (Min), High (First), Low (Max), Close (Last)
4. What is the function of "GET" in HTTP requests?
- Returns the response from the client to the requestor
- Carries the request to the client from the requestor
- Sends data to create or update a resource
- Deletes a specific resource
5. What does URL stand for?
- Uniform Request Location
- Uniform Resource Locator
- Unilateral Resistance Locator
- Uniform Resource Learning
6. What does the file extension “csv” stand for?
- Comma Separated Values
- Comma Separation Valuations
- Common Separated Variables
- Comma Serrated Values
7. What is webscraping?
- The process to display all data within a URL
- The process to describe communication options
- The process to extract data from a particular website
- The process to request and retrieve information from a client
Module 5 Graded Quiz
8. What are the 3 parts to a response message?
- HTTP headers, blank line, and body
- Bookmarks, history, and security
- Start or status line, header, and body
- Encoding, body, and cache
9. What is the purpose of this line of code "table_row=table.find_all(name=’tr’)" used in webscraping?
- It will find all of the data within the table marked with a tag “tr”
- It will find all of the data within the table marked with a tag “p”
- It will find all of the data within the table marked with a tag “h1”
- It will find all of the data within the table marked with a tag “a”
10. In what data structure do HTTP responses generally return?
- Tuples
- Lists
- Nested Lists
- JSON
11. The Python library we used to plot the chart in the lab is
- Pandas
- Plotly
- MatPlotLib
- PyCoinGecko
Final Exam
12. When slicing in Python what does the “0” in this statement [0:2] specify?
- It specifies the position to start the slice
- It specifies the step of the slicing
- It specifies the position to end the slice
13. If var = “01234567” what Python statement would print out only the odd elements?
- print(var[1::2])
- print(var[3::1])
- print(var[2::2])
14. Consider the string Name=”EMILY”, what statement would return the index of 0?
- Name.find(“E”)
- Name.find(“L”)
- Name.find(“I”)
15. In Python what data type is used to represent text and not numbers?
- int
- str
- float
16. What is the result of the following code segment: int(3.99)
- 3
- 3.99
- 4
17. What following code segment would produce an output of “0.5”?
- 1/2
- 1//2
18. In Python 3 what following code segment will produce an int?
- 2//3
- 1/2
19. How many identical keys can a dictionary have ?
- 100000000
- 0
- 3
20. What does the index of “1” correspond to in a list or tuple?
- the third
- The first element
- The second element
21. What is the result of the following operation: '1,2,3,4'.split(',') ?
- ‘1’,’2′,’3′,’4′
- [‘1′,’2′,’3′,’4’]
- (‘1′,’2′,’3′,’4’)
- ‘1234’
22. Tuples are:
- Not indexed
- Mutable
- Not mutable
- Unordered
23. What is a collection that is unordered, unindexed and does not allow duplicate members?
- Set
- Tuple
- List
24. If x=1 what will produce the below output?
Hi
Mike
if(x==1):
print(‘Hello’)
else:
print(‘Hi’)
print(‘Mike’)
if(x!=1):
print(‘Hello’)
else:
print(‘Hi’)
print(‘Mike’)
- if(x!=1):
print(‘Hi’)else:
print(‘Hello’)
print(‘Mike’)
25. What statement will execute the remaining code no matter the end result?
- If
- For
- While
- Finally
26. What add function would return ‘2’ ?
- def add(x): return(x+x) add(‘1’)
- def add(x): return(x+x) add(1)
- def add(x): return(x+x+x) add(‘1’)
27. What function returns a sorted list?
- sorted()
- lower()
- sort()
- find()
28. What is the output for the below line of code?
A=[8,5,2] for a in A: print(12-a)
8
5
2
4
7
10
888888888888
555555555555
222222222222
29. What is the output of the following?
for i in range(1,5): if (i!=2): print(i)
1
2
3
4
1
3
4
- 2
30. Consider the class Rectangle, what are the data attributes?
class Rectangle(object):
def __init__(self,width=2,height =3,color='r'):
self.height=height
self.width=width
self.color=color
def drawRectangle(self):
import matplotlib.pyplot as plt
plt.gca().add_patch(plt.Rectangle((0, 0),self.width,
self.height ,fc=self.color))
plt.axis('scaled')
plt.show()
- drawRectangle
- __init__
- self.height, self.width,self.color
31. What is the result of the following lines of code?
a=np.array([0,1,0,1,0]) b=np.array([1,0,1,0,1]) a/b
- array([0.1, 1.0, 0.1, 1.0, 0.1])
- array([1, 1, 1, 1, 1])
- Division by zero error
32. What is the result of the following lines of code?
a=np.array([1,1,1,1,1]) a+10
- array([10,10,10,10,10])
- array([1,1,1,1,1])
- array([11, 11, 11, 11, 11])
33. What does the following line of code select along with the headers ‘Artist’, ‘Length’ and ‘Genre’ from the dataframe df?
y=df[['Artist','Length','Genre']]
- The entire dataframe
- Rows
- Columns
34. Consider the file object: File1. How would you print the first two lines of text?
- file1.readline(4)
- for n in range(0,2): print(file1.readline())
35. Consider the following line of code:
with open("Example.txt","a") as file1:
What mode is the file object in?
- append
- read
- write
36. What is the extraction of data from a website?
- Web crawling
- Data mining
- Webscraping