🌍 All Study Guides📊 Dashboard📰 Blog💡 About
IBM Applied AI to IBM AI Developer Professional Certificate • STUDY MODE

PRACTICE QUIZ

QUESTION 1 OF 44

What are the keys of the following dictionary: {"a":1,"b":2} Explanation, the key is the first element separated from its value by a colon.

A
"a","b"Correct Answer
B
1,2
QUESTION 2 OF 44

Consider the following Python Dictionary: Dict={"A":1,"B":"2","C":[3,3,3],"D":(4,4,4),'E':5,'F':6} What is the result of the following operation: Dict["D"] Explanation, this corresponds to the key 'D' or Dict['D']

A
1
B
(4, 4, 4)Correct Answer
C
[3,3,3]
QUESTION 3 OF 44

Consider the following tuple: say_what=('say',' what', 'you', 'will') what is the result of the following say_what[-1] Explanation. An index of -1 corresponds to the last index of the tuple, in this case, the string 'will'.

A
'say'
B
' what'
C
'you'
D
'will'Correct Answer
QUESTION 4 OF 44

Consider the following tuple A=(1,2,3,4,5), what is the result of the following:A[1:4]: Explanation. These indexes correspond to elements 1,2 and 3 of the tuple.

A
(2, 3, 4)Correct Answer
B
(3, 4,5)
C
(2, 3, 4,5)
QUESTION 5 OF 44

Consider the following tuple A=(1,2,3,4,5), what is the result of the following: len(A) Explanation. The function len returns the number of items of a tuple.

A
4
B
5Correct Answer
C
6
QUESTION 6 OF 44

Consider the following list B=[1,2,[3,'a'],[4,'b']], what is the result of the following:B[3][1]

A
[4,"b"]
B
"b"Correct Answer
C
"c"
QUESTION 7 OF 44

What is the result of the following operation [1,2,3]+[1,1,1]

A
[2,3,4]
B
[1, 2, 3, 1, 1, 1]Correct Answer
C
TypeError
Explanation:

The addition operator corresponds to concatenating a list.

QUESTION 8 OF 44

What is the length of the list A = [1] after the following operation: A.append([2,3,4,5])

A
5
B
6
C
2Correct Answer
Explanation:

Append only adds one element to the list .

QUESTION 9 OF 44

What is the result of the following: "Hello Mike".split()

A
["H"]
B
["Hello","Mike"]Correct Answer
C
["HelloMike"]
Explanation:

The method split separates a string into a list based on the argument. If there is no argument as in this case the string is split using spaces. PRACTICE QUIZ

QUESTION 10 OF 44

Consider the following set: {"A","A"}, what will the result be when the set is created? Explanation, there are no duplicate values in a set

A
{"A","A"}
B
{"A"}Correct Answer
QUESTION 11 OF 44

What is the result of the following: type(set([1,2,3])) Explanation, the function set casts the list to a set before we apply the type function

A
setCorrect Answer
B
list
QUESTION 12 OF 44

What method do you use to add an element to a set?

A
extend
B
append
C
addCorrect Answer
QUESTION 13 OF 44

What is the result of the following operation : {'a','b'} &{'a'} Explanation, the intersection operation finds the elements that are in both sets. MODULE 2 GRADED QUIZ

A
{'a'}Correct Answer
B
{'a','b'}
QUESTION 14 OF 44

Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[1] ? Explanation, the index 1 corresponds to the second element in the tuple, which contains another list.

A
(11,12)
B
[21,22]Correct Answer
C
((11,12),[21,22])
QUESTION 15 OF 44

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]? Explanation, A[0] corresponds to the first nested tuple; we then access the second element of the tuple using the index 1 i.e A[0][1].

A
21
B
11
C
12Correct Answer
QUESTION 16 OF 44

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

A
TrueCorrect Answer
B
False
QUESTION 17 OF 44

Consider the following list : A=["hard rock",10,1.2] What will list A contain after the following command is run: del(A[0]) ? Explanation, we will delete element zero

A
[10,1.2]Correct Answer
B
["hard rock",10,1.2]
C
["hard rock",10]
QUESTION 18 OF 44

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

A
assigns list A to list B
B
variable B references a new copy or clone of the original list ACorrect Answer
QUESTION 19 OF 44

What is the result of the following: len(("disco",10,1.2, "hard rock",10)) ? Explanation, there are 5 elements in the tuple so the function len returns 5

A
5Correct Answer
B
6
C
0
QUESTION 20 OF 44

Consider the following dictionary: { "The Bodyguard":"1992", "Saturday Night Fever":"1977"} select the values Explanation this is a value

A
"1977"Correct Answer
B
"1992"Correct Answer
C
"The Bodyguard"
D
"Saturday Night Fever"
QUESTION 21 OF 44

The variable release_year_dict is a Python Dictionary, what is the result of applying the following method: release_year_dict.values() ? Explanation, this method returns the values

A
retrieve the keys of the dictionary
B
retrieves, the values of the dictionaryCorrect Answer
QUESTION 22 OF 44

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

A
error
B
{'A','B'}
C
{'A','B','C'}Correct Answer
QUESTION 23 OF 44

What is the result of the following: 'A' in {'A','B'} ?

A
False
B
TrueCorrect Answer
QUESTION 24 OF 44

Consider the tuple A=((1),[2,3],[4]), that contains a tuple and list. What is the result of the following operation A[2] ? Explanation, the index 2 corresponds to the third element in the tuple, which contains another list.

A
[4]Correct Answer
B
[2,3]
C
1
QUESTION 25 OF 44

Consider the following list : A=["hard rock",10,1.2] What will list A contain affter the following command is run: del(A[1]) ? Explanation , we will delete element 1

A
[10,1.2]
B
["hard rock",1.2]Correct Answer
C
["hard rock",10]
QUESTION 26 OF 44

What is the result of the following: len(("disco",10)) ? Explanation, there are 2 elements in the tuple so the function len returns 2

A
2Correct Answer
B
6
C
5
QUESTION 27 OF 44

Consider the following dictionary: { "The Bodyguard":"1992", "Saturday Night Fever":"1977"} select the keys Explanation, this is one of the keys

A
"1992"
B
"1977"
C
"Saturday Night Fever"Correct Answer
D
"The Bodyguard"Correct Answer
QUESTION 28 OF 44

Consider the Set: V={'1','2'}, what is the result of V.add('3')?

A
{'1','2'}
B
{1,2,3}
C
{'1','2','3'}Correct Answer
QUESTION 29 OF 44

What is the result of the following: '1' in {'1','2'} ?

A
False
C
TrueCorrect Answer
QUESTION 30 OF 44

What is the syntax to clone the list A and assign the result to list B ?

A
B=A
B
B=A[:]Correct Answer
QUESTION 31 OF 44

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]? Explanation, A[2] corresponds to the third nested list; we then access the only element of the list using the index 0 i.e. A[2][0].

A
4Correct Answer
B
[4]
C
1
QUESTION 32 OF 44

The method append does the following: Explanation, append-only adds one element.

A
adds one element to a listCorrect Answer
B
merges two lists or insert multiple elements to a list
QUESTION 33 OF 44

The variable release_year_dict is a Python Dictionary, what is the result of applying the following method: release_year_dict.keys() ? Explanation, the method returns the keys

A
retrieve the keys of the dictionaryCorrect Answer
B
retrieves, the values of the dictionary
QUESTION 34 OF 44

What are the keys of the following dictionary: {“a”:1,”b”:2}

A
“a”,”b”Correct Answer
B
1,2
QUESTION 35 OF 44

Consider the following Python Dictionary:

A
1
B
(4, 4, 4)Correct Answer
C
[3,3,3]
QUESTION 36 OF 44

Consider the following tuple:

A
‘say’
B
‘ what’
C
‘you’
D
‘will’Correct Answer
QUESTION 37 OF 44

Consider the following tuple A=(1,2,3,4,5), what is the result of the following:A[1:4]:

A
(2, 3, 4)Correct Answer
B
(3, 4,5)
C
(2, 3, 4,5)
QUESTION 38 OF 44

Consider the following tuple A=(1,2,3,4,5), what is the result of the following: len(A)

A
4
B
5Correct Answer
C
6
QUESTION 39 OF 44

Consider the following list B=[1,2,[3,’a’],[4,’b’]], what is the result of the following:B[3][1]

A
 [4,”b”]
B
“b”Correct Answer
C
“c”
QUESTION 40 OF 44

What is the result of the following operation

A
[2,3,4]
B
[1, 2, 3, 1, 1, 1]Correct Answer
C
TypeError     
QUESTION 41 OF 44

What is the result of the following: “Hello

A
Mike”.split()
B
[“H”]
C
[“Hello”,”Mike”]Correct Answer
D
 [“HelloMike”]
QUESTION 42 OF 44

Consider the following set: {“A”,”A”}, what will the result be when the set is created? 

A
{“A”,”A”}
B
{“A”}  Correct Answer
QUESTION 43 OF 44

What is the result of the following: type(set([1,2,3]))

A
setCorrect Answer
B
list
QUESTION 44 OF 44

What is the result of the following operation : {‘a’,’b’} &{‘a’}

A
{‘a’}Correct Answer
B
{‘a’,’b’}

Ready to test your recall?

What are the keys of the following dictionary: {"a":1,"b":2} Explanation, the key is the first element separated from its value by a colon.

A
"a","b"
B
1,2

How confident are you in this answer?