TN Online TestSamacheer Kalvi practice

Lists, Tuples, Sets and Dictionary: One Mark Questions, Book Back Answers and Notes

12th Standard · Computer Science · #9

Python has four built-in collection types: list, tuple, set and dictionary. This chapter explains how to create each one, access and change its elements, add and delete items, and use list comprehensions, tuple assignment, set operations and key-value lookups, with attention to which types can be changed and which allow duplicates.

Study this chapter

Asked in previous board exams

6 questions from this chapter came in 6 past public exams. Open any of them to see the answer and explanation.

  1. March 2026
    If mylist=[10, 20, 30, 40] then mylist.append(35) will result:
    See answer in the solved paper →
  2. March 2024
    If List = [10, 20, 30, 40, 50] then List [2] = 35 will result :
    See answer in the solved paper →
  3. March 2023
    Let set A={3, 6, 9}, set B={1, 3, 9}.
    The result of the following snippet Print (set A|set B)
    See answer in the solved paper →
  4. May 2022
    If List = [17, 23, 41, 10] then, List.append(32) will result :
    See answer in the solved paper →
  5. Supplementary 2021
    Let List = [2, 4, 6, 8, 10], then print(List[-2]) will result in :
    See answer in the solved paper →
  6. March 2020
    The keys in Python dictionary is specified by :
    See answer in the solved paper →

About Lists, Tuples, Sets and Dictionary

Medium ~120 min study

A variable such as mark = 85 holds one value. To store the marks of forty students you need one name that holds many values, and that is what a collection does. Python gives you four: lists, tuples, sets and dictionaries.

The differences between them decide which one you choose. A list keeps items in order and lets you change them. A tuple also keeps order but cannot be changed after it is made. A set holds only unique items with no fixed order, and supports union and intersection as in mathematics. A dictionary stores pairs, each key linked to a value, so you look up a value by its key rather than by position.

Many exam questions depend on brackets alone: [ ] makes a list, ( ) a tuple, and { } a set or a dictionary depending on whether the items have colons. Empty braces {} make an empty dictionary; an empty set must be written set(). Others ask for the output after append(), extend(), insert(), pop() or clear(), or the result of a set operation. Write the collection down after each step and check it against the code.

What you'll learn

  • Compare lists, tuples, sets and dictionaries by mutability, ordering and whether duplicates are allowed.
  • Predict the list after append(), extend(), insert(), remove(), pop() and clear().
  • Write list comprehensions that generate values under a given condition.
  • Use tuples for fixed data, tuple assignment and returning several values from a function.
  • Find the union, intersection, difference and symmetric difference of two sets.
  • Create a dictionary, read values by key, and add, change and delete pairs.

Before you start

  • Python variables, data types and operators.
  • while and for loops and if statements.
  • Defining functions with parameters and return values.

Topics covered in this chapter

Features of Lists Lists are ordered and mutable, written in square brackets, accessed by positive or negative index and able to hold values of different types.
Adding and Deleting List Elements append(), extend() and insert() add elements; del, remove(), pop() and clear() delete them.
List Comprehensions A one-line way to build a list from a loop and an optional condition, such as [x * x for x in range(1, 11)].
Tuples Compared with Lists Tuples are ordered like lists but immutable, written with commas and usually parentheses, and faster to iterate over.
Tuple Assignment A tuple of variables on the left receives the values on the right in one statement, as in (a, b, c) = (34, 90, 76).
Creating Sets Sets are mutable, unordered collections in curly braces that keep only one copy of each value.
Set Operations Union (|), intersection (&), difference (-) and symmetric difference (^), each also available as a set method.
Dictionaries Collections of unique, case-sensitive keys each linked to a value, where values are read, added and changed through their keys.

Lists, Tuples, Sets and Dictionary explained

Python Collections: List, Tuple, Set and Dictionary

Lists: Ordered and Changeable

A list is written in square brackets, such as Marks = [10, 23, 41, 75], and can hold values of different types. Each element has an index starting at 0, and negative indexes count from the end, so Marks[-1] is 75. Lists are mutable. append() adds one element at the end, extend() adds all the elements of another list, and insert(position, value) places an element at a chosen index. To delete, use del with an index or slice, remove(value) to delete the first matching value, pop() to remove an element by index (the last one if no index is given) and clear() to empty the list. A list comprehension builds a list in one line, for example [x * x for x in range(1, 11)] gives the squares of 1 to 10.

Tuples: Ordered but Unchangeable

A tuple is a sequence of values separated by commas, usually written in parentheses, such as Tup = (10, 20, 30). Tuples are immutable: you cannot change, add or remove an element once the tuple is created, though del Tup removes the whole tuple. Because they cannot change, Python iterates over tuples faster than over lists. A single-element tuple needs a trailing comma: (10,). Tuple assignment lets you assign several variables at once, as in (a, b, c) = (34, 90, 76), and a function can return several values together as a tuple. Tuples can also be nested inside other tuples.

Sets: Unique Elements, No Order

A set is a mutable collection written in curly braces, such as S = {1, 2, 2, 3}. It keeps no duplicates, so S holds only 1, 2 and 3, and it has no index positions. Sets support the mathematical operations. Union (| or union()) gives all elements of both sets. Intersection (& or intersection()) gives the common elements. Difference (- or difference()) gives elements in the first set but not in the second. Symmetric difference (^ or symmetric_difference()) gives elements that are in either set but not in both.

Dictionaries: Key-Value Pairs

A dictionary stores pairs written as key: value inside curly braces, such as Dict = {'Rollno': 1234, 'Name': 'Murali'}. You reach a value through its key, Dict['Name'], not through a numeric position. Keys must be unique and are case-sensitive, so 'Name' and 'name' are different keys. A key can be any immutable value such as a string, a number or a tuple. Assigning to a new key adds a pair; assigning to an existing key replaces its value. del Dict['Name'] removes one pair, clear() empties the dictionary and del Dict removes the dictionary itself.

Common mistakes to avoid

  • Trying to change a tuple element, as in t[0] = 5, which gives a TypeError. Convert the tuple to a list with list(t) if you need to change it.
  • Using append() to add several elements. a.append([4, 5]) adds one element, the list [4, 5]; a.extend([4, 5]) adds 4 and 5 separately.
  • Writing (10) for a one-element tuple. Without the comma it is just the integer 10; write (10,).
  • Expecting a set to keep the order in which elements were typed, or trying to use S[0]. Sets have no index positions.
  • Repeating a key in a dictionary. Only one copy is kept, and the later value replaces the earlier one without any error.

Test yourself on these with the practice test, then check the worked reasoning in the solved MCQs.

Frequently asked questions

What is the main difference between a list and a tuple?

A list is mutable and written in square brackets, so you can add, change and remove elements. A tuple is immutable and usually written in parentheses, so its elements cannot be changed after creation. Because of this, Python iterates over a tuple faster than over a list.

How do you create a tuple with only one element?

Put a comma after the element: t = (10,). Without the comma, (10) is treated as the integer 10 inside ordinary brackets. You can check this with type((10,)), which gives tuple, and type((10)), which gives int.

What happens to duplicate values in a set?

A set stores each value only once. If you write {1, 2, 2, 3} or add a value that is already present, the extra copy is simply dropped and no error is raised. The set here contains just 1, 2 and 3.

What is the difference between clear() and del?

clear() removes all elements but keeps the object, so a list becomes [] and a dictionary becomes {}. del with only the name, as in del Marks, removes the variable itself; using Marks after that gives a NameError.

What is a list comprehension?

It is a short way to build a list by writing the loop, and an optional condition, inside square brackets. For example, [x for x in range(1, 21) if x % 2 == 0] gives the even numbers from 2 to 20. It replaces a for loop with append() in a single readable line.

Can any value be used as a dictionary key?

No. Keys must be unique and of an immutable type, such as a string, integer or tuple. A list cannot be a key because it can change, and Python raises a TypeError if you try. Values, on the other hand, can be of any type.

Last updated 15 September 2026

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 5 Python Variables and Operators 6 Control Structures 7 Python Functions 8 Strings and String Manipulation 10 Python Classes and Objects 11 Database Concepts 12 Structured Query Language (SQL) 13 Python and CSV Files 14 Importing C++ Programs in Python 15 Data Manipulation through SQL 16 Data Visualization using Pyplot: Line Chart, Pie Chart and Bar Chart