LearnFrenzy
Sign in Take a free test

Tuples · Exercise 1 of 4

Tuples Tuples MCQ

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Fifteen multiple-choice questions on Python tuples: creation, single-element tuples, immutability, unpacking, methods, hashability, comparison and namedtuple. Pick an option to check your answer instantly.

Question 11 Medium

After first, *rest = (1, 2, 3), what is rest?

A (2, 3) – a tuple
B 2
C [2, 3] – a list
D [1, 2, 3]
Question page & discussion
Question 12 Medium

What does collections.namedtuple add over a plain tuple?

A It makes the tuple mutable
B It allows any number of items
C It sorts the fields automatically
D Fields can be accessed by name (p.x) as well as by index
Question page & discussion
Question 13 Easy

How do you get a tuple with 4 added to t = (1, 2, 3)?

A t + 4
B t.append(4)
C t + (4,)
D t.add(4)
Question page & discussion
Question 14 Hard

With t = ([1],), what does t[0] += [2] do?

A It raises TypeError – but the list inside t has already become [1, 2]
B It works silently
C It raises TypeError and t is unchanged
D It replaces t with ([1, 2],)
Question page & discussion
Question 15 Easy

Which data fits a tuple better than a list?

A A shopping cart that changes
B A GPS coordinate (latitude, longitude)
C A growing log of events
D A to-do list
Question page & discussion
Up next · Exercise 2Predict the Output15 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links