You have a request ? Contact Us Join Us

Python for Data Science, AI & Development | Coursera Quiz Answers

Answer Coursera: IBM Data Analyst Professional Certificate - Python for Data Science, AI & Development
Coursera: Python for Data Science, AI & Development Answers
Python for Data Science, AI & Development | Coursera IBM

Kickstart your Python learning journey with this self-paced, beginner-friendly course led by an expert. Python is a leading language in programming and data science, and the demand for those proficient in it is at an all-time high.

This introductory Python course will take you from a complete beginner to a competent programmer within hours—no prior programming experience needed! You will cover Python fundamentals, various data types, and familiarize yourself with data structures like lists and tuples. Additionally, you will explore logical concepts such as conditions and branching, and utilize Python libraries including Pandas, Numpy, and Beautiful Soup. You will also learn to perform tasks such as data collection and web scraping using APIs.

Hands-on labs using Jupyter Notebooks will allow you to practice and apply what you've learned. By the end of the course, you’ll be confident in creating basic programs, handling data, and automating real-world tasks with Python. This course is ideal for those interested in Data Science, Data Analytics, Software Development, Data Engineering, AI, DevOps, and numerous other job roles.


Notice!
Always refer to the module on your course for the most accurate and up-to-date information.

Attention!
If you have any questions that are not covered in this post, please feel free to leave them in the comments section below. Thank you for your engagement.

Module 1 Graded Quiz

1. What is the value of x after the following lines of code?
x=2
x=x+2
  • 4
  • 2
2. What is the result of the following operation 1+3*2 ?
  • 7
  • 12
  • 8
3. What is the type of the following "7.1"
  • float
  • string
4. What is the result of the following code segment: int(False)
  • 1
  • 0
  • error
5. In Python, what is the result of the following operation: '1'+'2' ?
  • 3
  • '3'
  • '12'
6. What is the result of the following: 'hello'.upper() ?
  • 'HELLO'
  • 'Hello'
  • 'hello'
7. What is the result of the following : str(1)+str(1) ?
  • '11'
  • 2
8. What is the result of the following: "123".replace("12", "ab") ?
  • 'ab3'
  • '123ab'
9. In Python 3, what is the type of the variable x after the following: x=2/2 ?
  • float
  • int

Module 2 Graded Quiz

1. Consider the tuple A=((1),[2,3],[4]), that contains a tuple and list. What is the result of the following operation A[2] ?
  • [4]
  • [2,3]
  • 1
2. Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[0][1]?
  • 21
  • 11
  • 12
3. True or false: after applying the following method, L.append(['a','b']), the following list will only be one element longer.
  • True
  • False
4. Consider the following list : A=["hard rock",10,1.2]
    What will list A contain after the following command is run: del(A[0]) ?
  • [10,1.2]
  • ["hard rock",10,1.2]
  • ["hard rock",10]
5. What is the syntax to clone the list A and assign the result to list B ?
  • B=A
  • B=A[:]
6. What is the result of the following: len(("disco",10)) ?
  • 2
  • 6
  • 5
7. Consider the following dictionary:
    { "The Bodyguard":"1992", "Saturday Night Fever":"1977"}
    select the values
  • "1977"
  • "1992"
  • "The Bodyguard"
  • "Saturday Night Fever"
8. The variable release_year_dict is a Python Dictionary, what is the result of applying the following method: release_year_dict.keys() ?
  • retrieve the keys of the dictionary
  • retrieves, the values of the dictionary
9. Consider the Set: V={'1','2'}, what is the result of V.add('3')?
  • {'1','2','3'}
  • {'1','2'}
  • {1,2,3}
10. What is the result of the following: 'A' in {'A','B'} ?
  • True
  • False

Module 3 Graded Quiz

1. What is the output of the following code?
x="Go" 

if(x=="Go"): 
	print('Go ') 
else: 
	print('Stop')
    
print('Mike')
  • Go Mike
  • Mike
  • Stop Mike
2. What is the result of the following lines of code?
x=1
x>5
  • True
  • False
3. What is the output of the following few lines of code?
x=5
while(x!=2):  
	print(x)  
    x=x-1
  • 5 4 3
  • 5 4 3 2
  • the program will never leave the loop
4. What is the result of running the following lines of code ?
class Points(object):  
	def __init__(self,x,y):     
    	self.x=x    
        self.y=y   
        
    def print_point(self):     
    	print('x=',self.x,' y=',self.y) 

p1=Points("A","B")
p1.print_point()
  • x= A
  • y= B
  • x= A   y= B
5. What is the output of the following few lines of code?
for i,x in enumerate(['A','B','C']):    
	print(i,2*x)
  • 0 AA 1 BB 2 CC
  • 0 A 1 B 2 C 
  • 0 A 2 B 4 C
6. What is the result of running the following lines of code ?
class Points(object):   
	def __init__(self,x,y):     
    	self.x=x    
        self.y=y   
    def print_point(self):     
    	print('x=',self.x,' y=',self.y) 

p2=Points(1,2) 
p2.x='A' 
p2.print_point()
  • x= 1 y=2
  • x= A  y=2
  • x=A, y=B
7. Consider the function delta, when will the function return a value of 1?
def delta(x):  
	if x==0:    
    	y=1  
    else:    
    	y=0  
    return(y)
  • When the input is anything but 0
  • When the input is 1
  • Never
  • When the input is 0
8. What is the output of the following lines of code?
a=1 

def do(x):    
	return(x+a) 

print(do(1))
  • 2
  • 1
  • NameError: name 'a' is not defined
9. Write a function name add that takes two parameter a and b, then return the output of  a + b (Do not use any other variable! You do not need to run it. Only write the code about how you define it.)
def add(a,b):    
	return(a+b)

10. Why is it best practice to have multiple except statements with each type of error labeled correctly?
  • Ensure the error is caught so the program will terminate
  • In order to know what type of error was thrown and the
  • location within the program
  • To skip over certain blocks of code during execution
  • It is not necessary to label errors

Module 4 Graded Quiz

1. What is the result of the following lines of code?
a=np.array([0,1])
b=np.array([1,0])
np.dot(a,b) 
  • 0
  • 1
  • array([1,1])
2. What is the value of Z after the following code is run?

  
  • array([[1,1],[1,1]])
  • array([[1,0],[0,1]])
  • array([[0,1],[1,1]])
3. What values does the variable out take if the following lines of code are run?
X=np.array([[1,0,1],[2,2,2]]) 
out=X[0:2,2]
out
  • array([1,0])
  • array([1,2])
  • array([1,1])
4. What is the value of Z after the following code is run?
X=np.array([[1,0],[0,1]])
Y=np.array([[2,1],[1,2]]) 
Z=np.dot(X,Y)
  • array([[2,1],[1,2] ])
  • array([[2,0],[1,0]])
  • array([[3,1],[1,3] ])
5.Consider the following text file: Example1.txt:
This is line 1
This is line 2
This is line 3
What is the output of the following lines of code?
with open("Example1.txt","r") as file1:      
	FileContent=file1.read()        
    print(FileContent)
  • This is line 1 This is line 2 This is line 3
  • This is line 1
  • This
6. What do the following lines of code do?
with open("Example1.txt","r") as file1:    
	FileContent=file1.readlines()   
    print(FileContent)
  • Read the file "Example1.txt"
  • Write to the file “Example1.txt”
  • Append the file "Example1.txt"
7. What do the following lines of code do?
with open("Example.txt","w") as writefile:    
	writefile.write("This is line A\n")  
    writefile.write("This is line B\n")
  • Read the file "Example.txt"
  • Write to the file “Example.txt”
  • Append the file "Example.txt"
8. What task do the following lines of code perform?

  
  • Print out the content of Example2.txt.
  • Copy the text from Example2.txt to Example3.txt.
  • Check the mode of the open function for each file object.
9. Consider the dataframe df. How would you access the element in the 2nd row and 1st column?
  • df.iloc[1,0]
  • df.iloc[2,1]
  • df.iloc[0,1]
10. What function would you use to load a csv file in Pandas?
  • pd.read_csv
  • pd.read_excel

Module 5 Graded Quiz

1. What are the 3 parts to a response message?
  • Bookmarks, history, and security
  • HTTP headers, blank line, and body
  • Encoding, body, and cache
  • Start or status line, header, and body
2. 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 “p”
  • 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 “h1”
  • It will find all of the data within the table marked with a tag “a”
3. In what data structure do HTTP responses generally return?
  • Nested Lists
  • JSON
  • Lists
  • Tuples
4. The Python library we used to plot the chart in video/lab is
  • PyCoinGecko
  • Plotly
  • Pandas
  • MatPlotLib

Final Exam

1. In Python, if you executed name = 'Lizz', what would be the output of print(name[0:2])?
  • Li
  • Lizz
  • L
2. When slicing in Python what does the “2” in [::2] specify?
  • It specifies the step of the slicing
  • It specifies the position to start the slice
  • It specifies the position to end the slice
3. Consider the string Name="ABCDE", what is the result of the following operation Name.find("B") ?
  • 1
  • 0
  • 2
4. What is the type of the following: 1.0
  • float
  • int
  • str
5. What will happen if you cast a float to an integer?
  • An error will occur
  • It will remove decimal point
  • Nothing happens
6. What following code segment would produce an output of “0”?
  • 1/2
  • 1//2
7. In Python 3 what following code segment will produce a float?
  • 1/2
  • 2//3
8. A dictionary must have what type of keys?
  • Duplicate
  • Unique
  • Not changeable
9. What is a tuple?
  • A collection that is ordered and changeable
  • A collection that is unordered and changeable
  • A collection that is ordered and unchangeable
10. What is the result of the following operation: '1,2,3,4'.split(',') ?
  • '1234'
  • ['1','2','3','4']
  • '1','2','3','4'
  • ('1','2','3','4')
11. Lists are:
  • Unordered
  • Mutable
  • Not mutable
  • Not indexed
12. How do you cast the list A to the set a?
  • a.set()
  • a=A.dict()
  • a=set(A)
13. What will be the output if x=”7”?
if(x!=1): 
 print('Hi') 
else: 
 print('Hello') 
print('Mike') 
  • Hi
    Mike
  • Hello
    Mike
  • Mike
14. What statement will execute the remaining code no matter the end result?
  • If
  • Finally
  • While
  • For
15. What add function would return ‘2’ ?
  • def add(x): return(x+x) add(1) 
  • def add(x): return(x+x+x) add('1') 
  • def add(x): return(x+x) add('1') 
16.  A list cannot be sorted if it contains:
  • only same Case strings
  • only numeric values
  • concatenated strings
  • strings and numeric values
17. What is the output for the below line of code?
A=[8,5,2] for a in A: print(12-a) 
  • 888888888888
    555555555555
    222222222222
  • 8
    5
    2
  • 4
    7
    10
18. What is the output of the following?
 for i in range(1,5): if (i!=2): print(i) 
  • 1
    3
    4
  • 1
    2
    3
    4
19.  hat is the width of the rectangle in the class Rectangle?
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()
  • 0
  • 2
  • 3
20. What line of code would produce the following: array([0, 0, 0, 0, 0]) ?
  • a=np.array([0,1,0,1,0]) b=np.array([1,0,1,0,1]) a*b
  • a=np.array([0,1,0,1,0]) b=np.array([1,0,1,0,1]) a-b
  • a=np.array([0,1,0,1,0]) b=np.array([1,0,1,0,1]) a+b
21. What line of code would produce the following: array([11, 11, 11, 11, 11])?
  • a=np.array([1,1,1,1,1]) a+10
  • a=np.array([1,1,1,1,1]) 11-a
  • a=np.array([1,2,1,1,1]) a+10
22. How would you select the columns with the headers: Artist, Length and Genre from the dataframe df and assign them to the variable y ?
  • y=df[['Artist','Length','Genre']]
  • y=df['Artist','Length','Genre'] 
  • y=df[['Artist'],['Length'],['Genre']]
23. Consider the file object: File1.What would the following line of code output?
for n in range(0,2): print(file1.readline()) 
  • It would output the entire text file
  • It would output 2 characters from the text file
  • It would output the first 2 lines from the text file
24. What mode will write text at the end of the existing text in a file?
  • Read “r”
  • Write “w”
  • Append “a”
25. What is scheme, internet address and route a part of?
  • URL
  • Error message
  • Text file

Related Articles

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.