4.2.1.Quiz - sj50179/IBM-Data-Science-Professional-Certificate GitHub Wiki

TOTAL POINTS 7

Question 1 Consider the following tuple:

say_what=('say',' what', 'you', 'will')

what is the result of the following say_what[-1]

1 / 1 point

'will'

'say'

' what'

'you'

Correct Correct. An index of -1 corresponds to the last index of the tuple, in this case, the string 'will'.

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

1 / 1 point

(2, 3, 4)

(2, 3, 4,5)

(3, 4,5)

Correct Correct. These indexes correspond to elements 1,2 and 3 of the tuple.

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

1 / 1 point

4

6

5

Correct Correct. The function len returns the number of items of a tuple.

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

1 / 1 point

"b"

"c"

[4,"b"]

Correct Correct.

Question 5 What is the result of the following operation?

[1,2,3]+[1,1,1]

1 / 1 point

TypeError

[1, 2, 3, 1, 1, 1]

[2,3,4]

Correct Correct. The addition operator corresponds to concatenating a list.

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

1 / 1 point

2

5

6

Correct Correct. Append only adds one element to the list .

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

1 / 1 point

["Hello","Mike"]

["HelloMike"]

["H"]

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