Tuples in python: 18 flashcards
All 18 flashcards from this kit, free and with no sign-up.
1. What is a tuple in Python?
Show the answer
An **immutable**, ordered collection of items, written with parentheses `()`.
2. How do you create an empty tuple?
Show the answer
Use empty parentheses: `my_tuple = ()`
3. How do you create a single-element tuple?
Show the answer
Add a trailing comma: `single = (42,)`
4. What is the main difference between a list and a tuple?
Show the answer
A **list** is mutable (can be changed), a **tuple** is immutable (cannot be changed after creation).
5. How do you access the first element of a tuple `t = (10, 20, 30)`?
Show the answer
`t[0]` returns `10`.
6. What does `t[-1]` return for `t = ('a', 'b', 'c')`?
Show the answer
`'c'` — negative indexing accesses from the end.
7. Can you change an element inside a tuple after creation?
Show the answer
No, tuples are **immutable** — you cannot assign new values to indices.
8. What happens if you try `t[0] = 5` on a tuple?
Show the answer
Python raises a `TypeError: 'tuple' object does not support item assignment`.
9. How do you check the length of a tuple?
Show the answer
Use `len(tuple_name)`.
10. What is tuple unpacking? Give a simple example.
Show the answer
Assigning tuple items to variables in one line: `a, b = (1, 2)` gives `a=1`, `b=2`.
11. How do you concatenate two tuples `t1 = (1, 2)` and `t2 = (3, 4)`?
Show the answer
Use `+`: `t1 + t2` returns `(1, 2, 3, 4)`.
12. What does `(1, 2) * 3` produce?
Show the answer
`(1, 2, 1, 2, 1, 2)` — repetition of the tuple.
13. How do you check if an item exists in a tuple?
Show the answer
Use the `in` operator: `3 in (1, 2, 3)` returns `True`.
14. What is the result of `(10, 20, 30)[1:3]`?
Show the answer
`(20, 30)` — slicing returns a new tuple.
15. Why would you use a tuple instead of a list?
Show the answer
For **immutable** data (e.g., constants, dictionary keys) and better performance.
16. Can a tuple contain mutable objects like a list?
Show the answer
Yes, but the tuple itself remains immutable — you cannot replace the list, but you can modify the list's contents.
17. How do you convert a list `[1, 2, 3]` into a tuple?
Show the answer
Use `tuple([1, 2, 3])` → `(1, 2, 3)`.
18. What is the output of `type((1))` vs `type((1,))`?
Show the answer
`type((1))` is `<class 'int'>`, `type((1,))` is `<class 'tuple'>`.
Your notes can be a kit like these
Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.
- Chapter notes
- Flashcards
- Practice MCQs
- Scored tests
- Exam prep
Get Veda free See what students get
Free to start · No ads · Works in 42 languages