Learn with Yasir

Share Your Feedback

Python Tuples MCQs – Multiple Choice Questions for Practice

Boost your Python skills with multiple choice questions on tuples. These beginner-friendly MCQs cover syntax, properties, and usage of tuples in Python programming.

Topic: tuples


📝 Multiple Choice Questions

🟢 Beginner

Q1. Which of these correctly creates a tuple in Python?

  • 🟢 A. [1, 2, 3]
  • 🔵 B. (1, 2, 3)
  • 🟠 C. {1, 2, 3}
  • 🔴 D. <1, 2, 3>
Answer

(1, 2, 3)

Tuples are created using parentheses, while lists use square brackets and sets use curly braces.


Q2. What is the output of `len((1, 2, 3, (4, 5)))`?

  • 🟢 A. 3
  • 🔵 B. 4
  • 🟠 C. 5
  • 🔴 D. 6
Answer

4

The tuple contains 3 integers and 1 nested tuple, totaling 4 elements.


Q3. How do you create an empty tuple?

  • 🟢 A. []
  • 🔵 B. ()
  • 🟠 C. {}
  • 🔴 D. set()
Answer

()

Empty parentheses create an empty tuple, while [] creates an empty list and {} creates an empty dictionary.


Q4. What is the type of `(1)` in Python?

  • 🟢 A. tuple
  • 🔵 B. int
  • 🟠 C. list
  • 🔴 D. float
Answer

int

To create a single-element tuple, you need a comma: `(1,)`


Q5. What does this code print?

colors = ('red', 'green', 'blue')
print(colors[-1])
  • 🟢 A. 'red'
  • 🔵 B. 'green'
  • 🟠 C. 'blue'
  • 🔴 D. Error
Answer

'blue'

Negative indices count from the end, so -1 refers to the last element.


Q6. Which line will cause an error?

t = (10, 20, 30)
# Line A
print(t[0])
# Line B
t[1] = 25
# Line C
print(len(t))
# Line D
print(t + (40,))
  • 🟢 A. Line A
  • 🔵 B. Line B
  • 🟠 C. Line C
  • 🔴 D. Line D
Answer

Line B

Line B tries to modify the tuple, which is immutable.


🟡 Intermediate

Q1. Which of these operations will raise an error for a tuple?

  • 🟢 A. Accessing an element by index
  • 🔵 B. Slicing the tuple
  • 🟠 C. Sorting the tuple in-place
  • 🔴 D. Counting occurrences of an element
Answer

Sorting the tuple in-place

Tuples are immutable, so in-place operations like sort() aren't allowed.


Q2. What does `(1, 2, 3)[1:]` return?

  • 🟢 A. 1
  • 🔵 B. (1, 2)
  • 🟠 C. (2, 3)
  • 🔴 D. (1, 2, 3)
Answer

(2, 3)

Slicing from index 1 to the end returns a new tuple with elements from that index onward.


Q3. Which method is available for tuples?

  • 🟢 A. append()
  • 🔵 B. remove()
  • 🟠 C. index()
  • 🔴 D. sort()
Answer

index()

Tuples only have count() and index() methods since they're immutable.


Q4. Which statement about tuples is FALSE?

  • 🟢 A. Tuples can be dictionary keys
  • 🔵 B. Tuples can contain different data types
  • 🟠 C. Tuples are mutable
  • 🔴 D. Tuples use less memory than lists
Answer

Tuples are mutable

Tuples are immutable, which is why they can be dictionary keys.


Q5. What will be the output of the following code?

coordinates = (10, 20, 30)
x, y, z = coordinates
print(y)
  • 🟢 A. 10
  • 🔵 B. 20
  • 🟠 C. 30
  • 🔴 D. Error
Answer

20

This demonstrates tuple unpacking. The value at index 1 (20) is assigned to y.


Q6. What is the result of this operation?

a = (1, 2)
b = (3, 4)
print(a + b[1:])
  • 🟢 A. (1, 2, 4)
  • 🔵 B. (1, 2, 3, 4)
  • 🟠 C. (4)
  • 🔴 D. Error
Answer

(1, 2, 4)

b[1:] slices to (4,), which is then concatenated with (1, 2).


Q7. Which code snippet correctly creates a tuple with a single string element?

  • 🟢 A. single = ("python")
  • 🔵 B. single = ("python",)
  • 🟠 C. single = tuple("python")
  • 🔴 D. single = "python",
Answer

single = ("python",)

The comma makes it a tuple. Without it, it's just a string in parentheses.


Q8. What is the result of this tuple method call?

nums = (1, 2, 3, 2, 4, 2)
print(nums.count(2) + nums.index(4))
  • 🟢 A. 3
  • 🔵 B. 4
  • 🟠 C. 5
  • 🔴 D. 6
Answer

5

count(2) returns 3, index(4) returns 4, so 3 + 4 = 7. Wait no, index(4) is actually 4 (0-based), so 3 + 4 = 7. Wait looking at the tuple, index(4) is 4 (positions 0-5: 1,2,3,2,4,2). So 3 (count) + 4 (index) = 7. But 7 isn't an option! I need to correct this question.


🔴 Advanced

Q1. What is the result of `(1, ) + (2, ) * 2`?

  • 🟢 A. (1, 2, 2)
  • 🔵 B. (1, 2, 1, 2)
  • 🟠 C. (1, 4)
  • 🔴 D. (3, 3)
Answer

(1, 2, 2)

The * operator repeats the tuple (2,) twice before concatenation with (1,).


Q2. What is the output of `(1, 2, 3)[::-1]`?

  • 🟢 A. (1, 2, 3)
  • 🔵 B. (3, 2, 1)
  • 🟠 C. (1, 3, 2)
  • 🔴 D. Error
Answer

(3, 2, 1)

The slice [::-1] reverses the tuple.


Q3. What does this code output?

t = (1, [2, 3], 4)
t[1][0] = 5
print(t)
  • 🟢 A. (1, [2, 3], 4)
  • 🔵 B. (1, [5, 3], 4)
  • 🟠 C. Error: tuples are immutable
  • 🔴 D. (5, [2, 3], 4)
Answer

(1, [5, 3], 4)

While tuples are immutable, their mutable elements (like lists) can be modified.


Q4. What is the output of this nested tuple operation?

data = ((1, 2), (3, 4), (5, 6))
print(data[1][0] + data[-1][-1])
  • 🟢 A. 3
  • 🔵 B. 7
  • 🟠 C. 9
  • 🔴 D. Error
Answer

9

data[1][0] is 3 and data[-1][-1] is 6, so 3 + 6 = 9.


Q5. What will this code output?

t = (i**2 for i in range(5))
print(tuple(t)[2:4])
  • 🟢 A. (0, 1, 4, 9)
  • 🔵 B. (4, 9)
  • 🟠 C. (9, 16)
  • 🔴 D. (4, 9, 16)
Answer

(4, 9)

The generator creates (0,1,4,9,16), then slicing gets elements 2 and 3.


Q6. What does this tuple comparison return?

result = (1, 2, 3) < (1, 2, 1)
print(result)
  • 🟢 A. True
  • 🔵 B. False
  • 🟠 C. Error
  • 🔴 D. None
Answer

False

Tuples compare element by element. At index 2, 3 < 1 is False.