python for data science ai & development coursera week 2 quiz answers

Practice Quiz

1. Consider the following tuple:

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

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

  • ‘you’
  • ‘ what’
  • ‘will’
  • ‘say’

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

  • (2, 3, 4,5)
  • (2, 3, 4)
  • (3, 4,5)

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

  • 4
  • 5
  • 6

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

  • “c”
  • “b”
  • [4,”b”]

5. What is the result of the following operation?

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

  • [1, 2, 3, 1, 1, 1]
  • TypeError
  • [2,3,4]

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

  • 2
  • 6
  • 5

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

  • [“HelloMike”]
  • [“Hello”,”Mike”]
  • [“H”]

8. What are the keys of the following dictionary: {"a":1,"b":2}

  • 1,2
  • “a”,”b”

Shuffle Q/A 1

9. 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"]

  • [3,3,3]
  • (4, 4, 4)
  • 1

10. Consider the following set: {"A","A"}, what will the result be when the set is created?

  • {“A”}
  • {“A”,”A”}

Leave a Reply