Python Programming (2180711) MCQs

MCQs of Structured Types, Mutability and Higher-Order Functions

Showing 21 to 30 out of 48 Questions
21.
Which of the following is a Python tuple?
(a) [1, 2, 3]
(b) (1, 2, 3)
(c) {1, 2, 3}
(d) {}
Answer:

Option (b)

22.
Suppose t = (1, 2, 4, 3), which of the following is incorrect?
(a) print(t[3])
(b) t[3] = 45
(c) print(max(t))
(d) print(len(t))
Answer:

Option (b)

23.
What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:3]
(a) (1, 2)
(b) (1, 2, 4)
(c) (2, 4)
(d) (2, 4, 3)
Answer:

Option (c)

24.
What 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)
Answer:

Option (c)

25.
Tuples can’t be made keys of a dictionary.
(a) TRUE
(b) FALSE
Answer:

Option (b)

26.
What is the data type of (1)?
(a) Tuple
(b) Integer
(c) List
(d) Both tuple and integer
Answer:

Option (b)

27.
If a=(1,2,3,4), a[1:-1] is _________
(a) Error, tuple slicing doesn’t exist
(b) [2,3]
(c) (2,3,4)
(d) (2,3)
Answer:

Option (d)

28.
What type of data is: a=[(1,1),(2,4),(3,9)]?
(a) Array of tuples
(b) List of tuples
(c) Tuples of lists
(d) Invalid type
Answer:

Option (b)

29.
Which of these about a set is not true?
(a) Mutable data type
(b) Allows duplicate values
(c) Data type with unordered values
(d) Immutable data type
Answer:

Option (d)

30.
Which of the following is not the correct syntax for creating a set?
(a) set([[1,2],[3,4]])
(b) set([1,2,2,3,4])
(c) set((1,2,3,4))
(d) {1,2,3,4}
Answer:

Option (a)

Showing 21 to 30 out of 48 Questions