Frage 1
Frage
Keys in dictionary are of mutable type but values can be immutable.
Frage 2
Frage
List is enclosed in square brackets
Frage 3
Frage
Slicing is used to extract a part of the list
Frage 4
Frage
Each key is separated from its value by a colon.
Frage 5
Frage
Keys are unique and act as the index.
Frage 6
Frage
If a is a dictionary with some key-value pairs, what does a.popitem() do?
Antworten
-
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
Frage 7
Frage
What will be the output of the following Python code snippet?
>>> a={1:"A",2:"B",3:"C"}
>>> del a
Antworten
-
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
Frage 8
Frage
Which of the statements about dictionary values if false?
Antworten
-
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
Frage 9
Frage
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.get(5,4))
Antworten
-
Error, invalid syntax
-
A
-
5
-
4
Frage 10
Frage
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
Frage 11
Frage
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=" ")
Antworten
-
1 A 2 B 3 C
-
1 2 3
-
A B C
-
1:”A” 2:”B” 3:”C”
Frage 12
Frage
Which of these about a dictionary is false?
Antworten
-
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
Frage 13
Frage
Suppose list Example is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop()?
Antworten
-
[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]
Frage 14
Frage
To add a new element to a list we use which command?
Antworten
-
list1.add(5)
-
list1.append(5)
-
list1.addLast(5)
-
list1.addEnd(5)
Frage 15
Frage
Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
Frage 16
Frage
Suppose list1 is [1, 6, 9], what is sum(list1)?
Frage 17
Frage
Suppose list1 is [2445,133,12454,123], what is min(list1)?
Frage 18
Frage
Which of the following commands will create a list?
Antworten
-
list1 = list()
-
list1 = []
-
list1 = list([1, 2, 3])
-
all of the mentioned
Frage 19
Frage
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
Antworten
-
[2, 33, 222, 14]
-
Error
-
25
-
[25, 14, 222, 33, 2]
Frage 20
Frage
What will be the output of the following Python code?
>>>"Welcome to Python".split()
Antworten
-
[“Welcome”, “to”, “Python”]
-
(“Welcome”, “to”, “Python”)
-
{“Welcome”, “to”, “Python”}
-
“Welcome”, “to”, “Python”