Python for Data Science, AI & Development Quiz Answers

Python for Data Science, AI & Development Week 01 Quiz Answers

Quiz : Module 1 Graded Quiz Answers

Q1. What is the value of x after the following lines of code?

x=2

x=x+2

  • 4
  • 2

Q2. What is the result of the following operation 3+2*2 ?

  • 3
  • 7
  • 9

Q3. What is the type of the following “7.1”

  • float
  • string

Q4. What is the result of the following code segment: int(True)

  • 1
  • 0
  • error

Q5. In Python, what is the result of the following operation: ‘1’+’2′ ?

  • 3
  • ‘3’
  • ’12’

Q6. Given myvar = ‘hello’ , how would you return myvar as uppercase?

  • len(myvar)
  • myvar.find(‘hello’)
  • myvar.upper()

Q7. What is the result of the following : str(1+1) ?

  • ‘2’
  • ’11’

Q8. What is the result of the following: “ABC”.replace(“AB”, “ab”) ?

  • ‘abC’
  • ‘ABc’

Q9. In Python 3, what is the type of the variable x after the following: x=1/1 ?

  • float
  • int

Python for Data Science, AI & Development Week 02 Quiz Answers

Quiz : Module 2 Graded Quiz Answers

Q1. Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[1] ?

  • (11,12)
  • [21,22]
  • ((11,12),[21,22])

Q2. Consider the tuple A=((1),[2,3],[4]), that contains a tuple and list. What is the result of the following operation A[2][0]?

  • 4
  • [4]
  • 1

Q3. The method append does the following:

  • adds one element to a list
  • merges two lists or insert multiple elements to a list

Q4. Consider the following list : A=[“hard rock”,10,1.2]

What will list A contain affter the following command is run: del(A[1]) ?

  • [10,1.2]
  • [“hard rock”,1.2]
  • [“hard rock”,10]

Q5. If A is a list what does the following syntax do: B=A[:] ?

  • assigns list A to list B
  • variable B references a new copy or clone of the original list A

Q6. What is the result of the following: len((“disco”,10,1.2, “hard rock”,10)) ?

  • 5
  • 6
  • 0

Q7. Consider the following dictionary:

{ “The Bodyguard”:”1992″, “Saturday Night Fever”:”1977″}

select the values

  • 1977″
  • “1992”
  • “The Bodyguard”
  • “Saturday Night Fever

Q8. 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

Q9. Consider the Set: V={‘A’,’B’}, what is the result of V.add(‘C’)?

  • {‘A’,’B’,’C’}
  • error
  • {‘A’,’B’}

Q10. What is the result of the following: ‘1’ in {‘1′,’2’} ?

  • False
  • True

Python for Data Science, AI & Development Week 03 Quiz Answers

Quiz : Module 3 Graded Quiz Answers

Q1. 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

Q2. What is the result of the following lines of code?

x=1
x>-5
  • True
  • False

Q3. What is the output of the following few lines of code?

x=0
while(x<2):
    print(x)
    x=x+1
  • 0
  • 1
  • 0
  • 1
  • 2
  • 0
  • 1
  • 3
  • 4

Q4. 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(1,2)
p1.print_point()
  • x=1;
  • x=1 y=2
  • y=2

Q5. What is the output of the following few lines of code?

for i,x in enumerate(['A','B','C']):
    print(i+1,x)
  • 1 A
  • 2 B
  • 3 C
  • 0 A
  • 1 B
  • 2 C
  • 0 AA
  • 1 BB
  • 2 CC

Q6. 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

Q7. Consider the function step, when will the function return a value of 1?

def step(x):
    if x>0:
        y=1
    else:
        y=0
    return y
  • if x is larger than 0
  • if x is equal to or less then zero
  • if x is less than zero

Q8. What is the output of the following lines of code?

a=1

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

print(do(1))
  • 2
  • 101
  • 102

Python for Data Science, AI & Development Week 04 Quiz Answers

Quiz : Module 4 Graded Quiz Answers

Q1. 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])

Q2. What is the value of Z after the following code is run?

X=np.array([[1,0],[0,1]])
Y=np.array([[0,1],[1,0]])
Z=X+Y
  • array([[1,1],[1,1]])
  • array([[1,0],[0,1]])
  • array([[0,1],[1,1]])

Q3. 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])

Q4. What is the value of Z after the following code is run?

X=np.array([[1,0],[0,1]])
Y=np.array([[2,2],[2,2]])
Z=np.dot(X,Y)
  • array([[2,2],[2,2]])
  • array([[2,0],[0,2] ])
  • array([[3,2],[2,3]])

Q5. 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

Q6. 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”

Q7. What do the following lines of code do?

with open("Example.txt","a") as writefile:
  
  writefile.write("This is line A\n")
  writefile.write("This is line B\n")
  • Read the file “Example.txt”
  • Append the file “Example.txt”
  • Write to the file “Example.txt”

Q8. What task do the following lines of code perform?

with open('Example2.txt','r') as readfile:
    with open('Example3.txt','w') as writefile:
          for line in readfile:
                writefile.write(line)
  • Check the mode of the open function for each file object.
  • Copy the text from Example2.txt to Example3.txt.
  • Print out the content of Example2.txt.

Q9. Consider the dataframe df. How would you access the element in the 1st row 3rd column

  • df.iloc[2,0]
  • df.iloc[1,3]
  • df.iloc[0,2]

Q10. What method gets the unique elements of the following: df[‘Length’] ?

  • unique
  • head

Python for Data Science, AI & Development Week 05 Quiz Answers

Quiz : Module 5 Graded Quiz Answers

Q1. What are the 3 parts to a response message?

  • Start or status line, header, and body
  • Bookmarks, history, and security
  • Encoding, body, and cache
  • HTTP headers, blank line, and body

Q2. 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 “h1
  • It will find all of the data within the table marked with a tag “a
  • It will find all of the data within the table marked with a tag “p

Q3. In what data structure do HTTP responses generally return?

  • Tuples
  • Nested Lists
  • JSON
  • Lists

Q4. The Python library we used to plot the chart in the lab is

  • Plotly
  • MatPlotLib
  • Pandas
  • PyCoinGecko

Get all IBM Full Stack Cloud Developer Professional Certificate Quiz Answers

Introduction to Cloud Computing Coursera Quiz Answers

Introduction to Web Development with HTML, CSS, JavaScript Quiz Answers

Developing Cloud Native Applications Coursera Quiz Answers

Developing Cloud Apps with Node.js and React Coursera Quiz Answers

Introduction to Containers w/ Docker, Kubernetes & OpenShift Quiz Answers

Python for Data Science, AI & Development Coursera Quiz Answers

Python Project for AI & Application Development Coursera Quiz Answers

Developing Applications with SQL, Databases, and Django Quiz Answers

Application Development using Microservices and Serverless Quiz Answers

Full Stack Cloud Development Capstone Project Coursera Quiz Answers

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *