Tuples

Python Tuple Interview Questions

Tuples are fixed records you can unpack, and unlike lists they can be used as dictionary keys. That is what makes them the natural way to group by more than one column.

What tuple questions ask you to do

Across the questions here, these are the shapes that come up:

  • Group by a pair or a triple of values
  • Return several values from one function
  • Order by more than one key
  • Remove duplicates across several columns at once

Common mistakes with tuples

A tuple of one item needs a trailing comma. Brackets on their own are just brackets, and the mistake surfaces later as a confusing type error somewhere else in the program.

Questions to practice

Roles this comes up in

Companies these come from

Other topics