Online Test List & Dictionary

Description

Quiz on Online Test List & Dictionary, created by Aparna Dhirde on 03/17/2020.
Aparna Dhirde
Quiz by Aparna Dhirde, updated more than 1 year ago
Aparna Dhirde
Created by Aparna Dhirde over 4 years ago
34
0

Resource summary

Question 1

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

Question 2

Question
List is enclosed in square brackets
Answer
  • True
  • False

Question 3

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

Question 4

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

Question 5

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

Question 6

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 7

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 8

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

Question 9

Question
What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} print(a.get(5,4))
Answer
  • Error, invalid syntax
  • A
  • 5
  • 4

Question 10

Question
What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} print(a.get(1,4))
Answer
  • 1
  • A
  • 4
  • Invalid syntax for get method

Question 11

Question
What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} for i,j in a.items(): print(i,j,end=" ")
Answer
  • 1 A 2 B 3 C
  • 1 2 3
  • A B C
  • 1:”A” 2:”B” 3:”C”

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
Suppose list Example is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop()?
Answer
  • [3, 4, 5, 20, 5, 25, 1]
  • [1, 3, 3, 4, 5, 5, 20, 25]
  • [3, 5, 20, 5, 25, 1, 3]
  • [1, 3, 4, 5, 20, 5, 25]

Question 14

Question
To add a new element to a list we use which command?
Answer
  • list1.add(5)
  • list1.append(5)
  • list1.addLast(5)
  • list1.addEnd(5)

Question 15

Question
Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
Answer
  • error
  • none
  • 25
  • 2

Question 16

Question
Suppose list1 is [1, 6, 9], what is sum(list1)?
Answer
  • 1
  • 9
  • 16
  • error

Question 17

Question
Suppose list1 is [2445,133,12454,123], what is min(list1)?
Answer
  • 2445
  • 123
  • 133
  • 12454

Question 18

Question
Which of the following commands will create a list?
Answer
  • list1 = list()
  • list1 = []
  • list1 = list([1, 2, 3])
  • all of the mentioned

Question 19

Question
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
Answer
  • [2, 33, 222, 14]
  • Error
  • 25
  • [25, 14, 222, 33, 2]

Question 20

Question
What will be the output of the following Python code? >>>"Welcome to Python".split()
Answer
  • [“Welcome”, “to”, “Python”]
  • (“Welcome”, “to”, “Python”)
  • {“Welcome”, “to”, “Python”}
  • “Welcome”, “to”, “Python”
Show full summary Hide full summary

Similar

Blood Brothers (Characters)
nuhaheza
Art Movements
Julia Lee
River Processes and Landforms
1jdjdjd1
To Kill A Mockingbird Complete Notes
jessica.moscrip
Mind Maps with GoConqr
Manikandan Achan
History- Religion and medicine
gemma.bell
8 Citações Motivacionais para Estudantes
miminoma
5 Tips for motivating your students
Jen Molte
Conocimiento General de Aeronaves
Adriana Forero
Biology - B2 - AQA - GCSE - Exam Style Questions
Josh Anderson
SFDC App Builder 1 (126-150)
Connie Woolard