On line Test- Tuples and Dictionary

Descrição

Quiz sobre On line Test- Tuples and Dictionary, criado por Aparna Dhirde em 18-03-2020.
Aparna Dhirde
Quiz por Aparna Dhirde, atualizado more than 1 year ago
Aparna Dhirde
Criado por Aparna Dhirde quase 6 anos atrás
116
0

Resumo de Recurso

Questão 1

Questão
Slicing is used to extract a part of the tuple
Responda
  • True
  • False

Questão 2

Questão
Each key is separated from its value by a colon
Responda
  • True
  • False

Questão 3

Questão
Keys are unique and act as the index
Responda
  • True
  • False

Questão 4

Questão
Keys are of mutable type but values can be immutable
Responda
  • True
  • False

Questão 5

Questão
Elements of tuple is enclosed in square brackets
Responda
  • True
  • False

Questão 6

Questão
What will be the output of the following Python code? >>>t=(1,2,4,3) >>>t[1:-1]
Responda
  • (1, 2)
  • (1, 2, 4)
  • (2,4)
  • (2, 4, 3)

Questão 7

Questão
What will be the output of the following Python code? >>>t = (1, 2, 4, 3, 8, 9) >>>[t[i] for i in range(0, len(t), 2)]
Responda
  • [2, 3, 9]
  • [1, 2, 4, 3, 8, 9]
  • [1,4,8]
  • (1, 4, 8)

Questão 8

Questão
What will be the output of the following Python code? >>>t = (1, 2) >>>2 * t
Responda
  • [1, 2, 1, 2]
  • (1, 1, 2, 2)
  • [1, 1, 2, 2]
  • (1,2,1,2)

Questão 9

Questão
What will be the output of the following Python code? >>>t1 = (1, 2, 4, 3) >>>t2 = (1, 2, 3, 4) >>>t1 < t2
Responda
  • True
  • False
  • error
  • none

Questão 10

Questão
Which of the following statements create a dictionary?
Responda
  • d = {}
  • d = {“john”:40, “peter”:45}
  • d = {40:”john”, 45:”peter”}
  • All of the above

Questão 11

Questão
What will be the output of the following Python code snippet? d = {"john":40, "peter":45} "john" in d
Responda
  • True
  • False
  • error
  • none

Questão 12

Questão
Which of these about a dictionary is false?
Responda
  • The values of a dictionary can be accessed using keys
  • The keys of a dictionary can be accessed using values
  • Dictionaries aren’t ordered
  • Dictionaries are mutable

Questão 13

Questão
If a is a dictionary with some key-value pairs, what does a.popitem() do?
Responda
  • Removes an arbitrary element
  • Removes all the key-value pairs
  • Removes the key-value pair for the key given as an argument
  • Invalid method for dictionary

Questão 14

Questão
What will be the output of the following Python code snippet? >>> a={1:"A",2:"B",3:"C"} >>> del a
Responda
  • method del doesn’t exist for the dictionary
  • del deletes the values in the dictionary
  • del deletes the entire dictionary
  • del deletes the keys in the dictionary

Questão 15

Questão
Which of the statements about dictionary values if false?
Responda
  • More than one key can have the same value
  • The values of the dictionary can be accessed as dict[key]
  • Values of a dictionary must be unique
  • Values of a dictionary can be a mixture of letters and numbers