QuiztudyPREMIUM
IBM Applied AI to IBM AI Developer Professional Certificate • STUDY MODE
PRACTICE QUIZ
QUESTION 1 OF 39
what is the result of the following: 1=2 Explanation, this statement is a syntax error
A
TrueB
SyntaxError:can't assign to literalCorrect AnswerC
FalseQUESTION 2 OF 39
What is the output of the following code segment: i=6 i<5
A
TrueB
FalseCorrect AnswerC
SyntaxError: can't assign to literalQUESTION 3 OF 39
What is the result of the following: 5!=5 Explanation, this is the inequality operator
A
FalseCorrect AnswerB
TrueQUESTION 4 OF 39
What is the output of the following code segment: 'a'=='A' Explanation, the equality operator is case sensitive
A
FalseCorrect AnswerB
TrueQUESTION 5 OF 39
in the video, if age=18 what would be the result
A
move onCorrect AnswerB
you can enterQUESTION 6 OF 39
in the video what would be the result if we set the variable age as follows: age= -10
A
go see Meat LoafB
move onCorrect AnswerC
you can enterD
move onQUESTION 7 OF 39
what is the result of the following: True or False Explanation,an or statement is only False if all the Boolean values are False PRACTICE QUIZ
A
True, an or statement is only False if all the Boolean values are FalseCorrect AnswerB
FalseQUESTION 8 OF 39
what will be the output of the following: for x in range(0,3): print(x) 1 2 (CORRECT) 1 2 3
A
0B
0QUESTION 9 OF 39
what is the output of the following: for x in ['A','B','C']: print(x+'A') BA CA (CORRECT) B C
A
AAB
AQUESTION 10 OF 39
what is the output of the following: for i,x in enumerate(['A','B','C']): print(i,x) 1 B 2 C (CORRECT) BB CC PRACTICE QUIZ
A
0 AB
AAQUESTION 11 OF 39
What does the following function return: len(['A','B',1]) ? Explanation, the function returns the number of elements in the list, in this case 3.
A
3Correct AnswerB
2C
4QUESTION 12 OF 39
What does the following function return: len([sum([0,0,1])]) ?
A
1Correct AnswerB
0C
3QUESTION 13 OF 39
What is the value of list L after the following code segment is run : L=[1,3,2] sorted(L) Explanation, sorted is a function and returns a new list, it does not change the list L
A
L:[1,3,2]Correct AnswerB
L:[1,2,3]C
L:[0,0,0]QUESTION 14 OF 39
From the video what is the value of c after the following: c=add1(2) c=add1(10) Explanation, when you call the function the second time the value of c is reassigned.
A
3B
11Correct AnswerC
14QUESTION 15 OF 39
what is the output of the following lines of code: def Print(A): for a in A: print(a+'1') Print(['a','b','c']) b c b1 c1 (CORRECT) Explanation, the function concatenates a string PRACTICE QUIZ
A
aB
a1C
a1QUESTION 16 OF 39
Why do we use exception handlers?
A
Terminate a programB
Write a fileC
Read a fileD
Catch errors within a programCorrect AnswerQUESTION 17 OF 39
What is the purpose of a try…except statement? PRACTICE QUIZ
A
Crash a program when errors occurB
Catch and handle exceptions when an error occursCorrect AnswerC
Executes the code block only if a certain condition existsD
Only executes if one condition is trueQUESTION 18 OF 39
What is the type of the following? ["a"] Explanation, the "a" is surrounded by brackets so it is a list.
A
strB
listCorrect AnswerQUESTION 19 OF 39
What does a method do to an object?
A
Changes or interacts with the objectCorrect AnswerB
Returns a new valuesQUESTION 20 OF 39
We create the object: Circle(3,'blue') What is the color attribute set to?
A
2B
'blue'Correct AnswerQUESTION 21 OF 39
What is the radius attribute after the following code block is run? RedCircle=Circle(10,'red') RedCircle.radius=1 Explanation, the line of code RedCircle.radius=1 will change the radius.
A
10B
1Correct AnswerC
'red'QUESTION 22 OF 39
What is the radius attribute after the following code block is run? BlueCircle=Circle(10,'blue') BlueCircle.add_radius(20) MODULE 3 GRADED QUIZ
A
10B
20C
30Correct AnswerQUESTION 23 OF 39
What is the output of the following code? x="Go" if(x=="Go"): print('Go ') else: print('Stop') print('Mike')
A
Go MikeCorrect AnswerB
MikeC
Stop MikeQUESTION 24 OF 39
What is the result of the following lines of code? x=1 x>5
A
TrueB
FalseCorrect AnswerQUESTION 25 OF 39
What is the output of the following few lines of code? x=0 while(x<2): print(x) x=x+1 1 (CORRECT) 1 2 1 3 4
A
0B
0C
0QUESTION 26 OF 39
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()
A
x=1;B
x=1 y=2Correct AnswerC
y=2QUESTION 27 OF 39
What is the output of the following few lines of code? for i,x in enumerate(['A','B','C']): print(i,2*x) 1 BB 2 CC (CORRECT) 1 B 2 C 2 B 4 C
A
0 AAB
0 AC
0 AQUESTION 28 OF 39
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()
A
x= 1 y=2B
x= A y=2Correct AnswerC
x=A, y=BQUESTION 29 OF 39
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)
A
When the input is anything but 0B
When the input is 1Correct AnswerC
NeverD
When the input is 0QUESTION 30 OF 39
What is the output of the following lines of code? a=1 def do(x): return(x+a) print(do(1)) Explanation, the value of a in the global scope will be used
A
2Correct AnswerB
1C
NameError: name 'a' is not definedQUESTION 31 OF 39
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.) Answer: return(a+b)
A
def add(a,b):QUESTION 32 OF 39
Why is it best practice to have multiple except statements with each type of error labeled Explanationly?
A
Ensure the error is caught so the program will terminateB
In order to know what type of error was thrown and the location within the programCorrect AnswerC
To skip over certain blocks of code during executionD
It is not necessary to label errorsQUESTION 33 OF 39
What is the result of the following lines of code? x=1 x>-5
A
TrueCorrect AnswerB
FalseQUESTION 34 OF 39
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()
A
x= AB
y= BC
x= A y= BCorrect AnswerQUESTION 35 OF 39
What is the output of the following few lines of code? for i,x in enumerate(['A','B','C']): print(i+1,x) 2 B 3 C (CORRECT) 1 B 2 C 1 BB 2 CC
A
1 AB
0 AC
0 AAQUESTION 36 OF 39
What is the output of the following lines of code? a=1 def do(x): a=100 return(x+a) print(do(1)) Explanation, the value of a=100 exists in the local scope of the function. Therefore the value of a=1 in the global scope is not used.
A
2B
101Correct AnswerC
102QUESTION 37 OF 39
What is the output of the following few lines of code? x=5 while(x!=2): print(x) x=x-1 4 3 (CORRECT) 4 3 2
A
5B
5Explanation:
the program will never leave the loop
QUESTION 38 OF 39
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=2 p2.print_point()
A
x=2 y=2Correct AnswerB
x=1 y=2C
x=1 y=1QUESTION 39 OF 39
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 Explanation, the value of y is 1 only if x is larger than 0
A
if x is larger than 0Correct AnswerB
if x is equal to or less then zeroC
if x is less than zeroReady to test your recall?
what is the result of the following: 1=2 Explanation, this statement is a syntax error
A
True
B
SyntaxError:can't assign to literal
C
False
How confident are you in this answer?