Quiz
On line Test- Tuples and Dictionary
This quiz has a time limit, so it opens in the usual player.
Questions in this quiz (15)
1Slicing is used to extract a part of the tuple
- ATrue
- BFalse
2Each key is separated from its value by a colon
- ATrue
- BFalse
3Keys are unique and act as the index
- ATrue
- BFalse
4Keys are of mutable type but values can be immutable
- ATrue
- BFalse
5Elements of tuple is enclosed in square brackets
- ATrue
- BFalse
6What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:-1]- A(1, 2)
- B(1, 2, 4)
- C(2,4)
- D(2, 4, 3)
7What 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)]- A[2, 3, 9]
- B[1, 2, 4, 3, 8, 9]
- C[1,4,8]
- D(1, 4, 8)
8What will be the output of the following Python code?
>>>t = (1, 2)
>>>2 * t- A[1, 2, 1, 2]
- B(1, 1, 2, 2)
- C[1, 1, 2, 2]
- D(1,2,1,2)
9What will be the output of the following Python code?
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2- ATrue
- BFalse
- Cerror
- Dnone
10Which of the following statements create a dictionary?
- Ad = {}
- Bd = {“john”:40, “peter”:45}
- Cd = {40:”john”, 45:”peter”}
- DAll of the above
11What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
"john" in d- ATrue
- BFalse
- Cerror
- Dnone
12Which of these about a dictionary is false?
- AThe values of a dictionary can be accessed using keys
- BThe keys of a dictionary can be accessed using values
- CDictionaries aren’t ordered
- DDictionaries are mutable
13If a is a dictionary with some key-value pairs, what does a.popitem() do?
- ARemoves an arbitrary element
- BRemoves all the key-value pairs
- CRemoves the key-value pair for the key given as an argument
- DInvalid method for dictionary
14What will be the output of the following Python code snippet?
>>> a={1:"A",2:"B",3:"C"}
>>> del a- Amethod del doesn’t exist for the dictionary
- Bdel deletes the values in the dictionary
- Cdel deletes the entire dictionary
- Ddel deletes the keys in the dictionary
15Which of the statements about dictionary values if false?
- AMore than one key can have the same value
- BThe values of the dictionary can be accessed as dict[key]
- CValues of a dictionary must be unique
- DValues of a dictionary can be a mixture of letters and numbers
Information
- Description
- Quiz on On line Test- Tuples and Dictionary, created by Aparna Dhirde on 18/03/2020.
- Author
- Aparna Dhirde
- Language
- English
- Views
- 122
- Tags
- Rating
- No ratings yet Rate this quiz
More on Python Lists and Data Structures