Python for Data Science, AI & Development All Week Quiz Answers | IBM

Python for Data Science, AI & Development All Week Quiz Answers  IBM


Python for Data Science, AI & Development 
All Week Quiz Answers | IBM



------------------------------------------------------------------------------------------------------------------

        Module 1 Graded Quiz

------------------------------------------------------------------------------------------------------------------


Question 1)

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

x=1

x=x+1


  • 2


Question 2)

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

  • 7


Question 3)

What is the type of the following "7.1"

  • string


Question 4)

What is the result of the following code segment: int(False)

  • 0


Question 5)

In Python, what is the result of the following operation: '1'+'2' ?

  • '12'



Question 6)

Given myvar = 'hello' , how would you return myvar as uppercase ?

  • myvar.upper()


Question 7)

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

  • '11'


Question 8)

What is the result of the following: "123".replace("12", "ab") ?

  • 'ab3'


Question 9)

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

  • float





------------------------------------------------------------------------------------------------------------------

        Module 2 Graded Quiz

------------------------------------------------------------------------------------------------------------------




Question 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]


Question 2)
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


Question 3)
True or false: after applying the following method, L.append(['a','b']), the following list will only be one element longer.
  • True


Question 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]


Question 5)
What is the syntax to clone the list A and assign the result to list B ?
  • B=A[:]


Question 6)
What is the result of the following: len(("disco",10,1.2, "hard rock",10)) ?
  • 5


Question 7)
Consider the following dictionary:

{ "The Bodyguard":"1992", "Saturday Night Fever":"1977"} 

select  the keys 


  • "Saturday Night Fever"
  • "The Bodyguard"


Question 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


Question 9)
Consider the Set: V={'A','B'}, what is the result of V.add('C') ?
  • {'A','B','C'}


Question 10)
What is the result of the following: '1' in {'1','2'} ?
  • True





------------------------------------------------------------------------------------------------------------------

        Module 3 Graded Quiz

------------------------------------------------------------------------------------------------------------------




Question 1)

What is the output of the following code ?


x="Go"
    if(x=="Go"):
      print('Go ')
else:
      print('Stop')




  • Go Mike




Question 2)

What is the result of the following lines of code ?



x=1
x>-5


  • True


Question 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



Question 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)




  • x=1 y=2


Question 5)

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



Question 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)


  • x=2 y=2



Question 7)

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



Question 8)

What is the output of the following lines of code ?


a=1

def do(x):

a=100

return(x+a)

print(do(1))


  • 101



Question 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




Question 10)

Why is it best practice to have multiple except statements with each type of error labeled correctly?

  • In order to know what type of error was thrown and the location within the program





--------------------------------------------------------------------------------------------------------------------------------------------

        Module 4 Graded Quiz

-------------------------------------------------------------------------------------------------------------------------------------------------



Coming Soon

Post a Comment

1 Comments