4.2.1.Graded Quiz Lists&Tuples - sj50179/IBM-Data-Science-Professional-Certificate GitHub Wiki

LATEST SUBMISSION GRADE 100%

Question 1 What is the syntax to obtain the first element of the tuple?

A=('a','b','c')

1 / 1 point

A[1]

A[0]

A[:]

Correct correct, the index 0 corresponds to the first element of a list or tuple.

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

1 / 1 point

1

[2,3]

[4]

Correct correct, the index 2 corresponds to the third element in the tuple, which contains another list.

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

1 / 1 point

4

[4]

1

Correct correct, 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].

Question 4 What is the result of the following operation: '1,2,3,4'.split(',') ?

1 / 1 point

'1','2','3','4'

['1','2','3','4']

'1234'

('1','2','3','4')

Correct correct, split returns a list of the words in the string, separated by the delimiter string, in this case, a comma.

Question 5 The method append does the following:

1 / 1 point

adds one element to a list

merges two lists or insert multiple elements to a list

Correct correct, append-only adds one element.

Question 6 True or false: lists are mutable

1 / 1 point

True

False

Correct correct, lists are mutable tuples are not

Question 7 Consider the following list : A=["hard rock",10,1.2]

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

1 / 1 point

[10,1.2]

["hard rock",10,1.2]

["hard rock",10]

Correct correct, we will delete element zero

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

1 / 1 point

B=A

B=A[:]

Correct correct

Question 9 What is the result of the following: len(("disco",10)) ?

1 / 1 point

2

6

5

Correct correct, there are 2 elements in the tuple so the function len returns 2