Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

On line Test- Tuples and Dictionary

Description

Quiz on On line Test- Tuples and Dictionary, created by Aparna Dhirde on 18/03/2020.
Aparna Dhirde
Quiz by Aparna Dhirde, updated more than 1 year ago
Aparna Dhirde
Created by Aparna Dhirde over 5 years ago
112
0
1 2 3 4 5 (0)

Resource summary

Question 1

Question
Slicing is used to extract a part of the tuple
Answer
  • True
  • False

Question 2

Question
Each key is separated from its value by a colon
Answer
  • True
  • False

Question 3

Question
Keys are unique and act as the index
Answer
  • True
  • False

Question 4

Question
Keys are of mutable type but values can be immutable
Answer
  • True
  • False

Question 5

Question
Elements of tuple is enclosed in square brackets
Answer
  • True
  • False

Question 6

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

Question 7

Question
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)]
Answer
  • [2, 3, 9]
  • [1, 2, 4, 3, 8, 9]
  • [1,4,8]
  • (1, 4, 8)

Question 8

Question
What will be the output of the following Python code? >>>t = (1, 2) >>>2 * t
Answer
  • [1, 2, 1, 2]
  • (1, 1, 2, 2)
  • [1, 1, 2, 2]
  • (1,2,1,2)

Question 9

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

Question 10

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

Question 11

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

Question 12

Question
Which of these about a dictionary is false?
Answer
  • 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

Question 13

Question
If a is a dictionary with some key-value pairs, what does a.popitem() do?
Answer
  • 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

Question 14

Question
What will be the output of the following Python code snippet? >>> a={1:"A",2:"B",3:"C"} >>> del a
Answer
  • 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

Question 15

Question
Which of the statements about dictionary values if false?
Answer
  • 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
Show full summary Hide full summary

0 comments

There are no comments, be the first and leave one below:

Similar

AQA GCSE Biology Unit 2.3
Matthew T
French Tense Endings
James Hoyle
Basic Spanish Vocabulary
Alice McClean
Lord of the Flies - CFE Higher English
Daniel Cormack
AQA AS Biology Unit 2 DNA and Meiosis
elliedee
Roles of Education
Isobel Wagner
Musical Terms
Abby B
New GCSE history content
Sarah Egan
2PR101 1. test - 5. část
Nikola Truong
General Pathoanatomy Final MCQs (201-300)- 3rd Year- PMU
Med Student