1st pu notes

1st PUC Computer Science Chapter 10 Tuples and Dictionaries Notes | Class 11 Python Notes

Venkatesh A August 20, 2026 17 min read
1st PUC / Class 11 Computer Science
Chapter 10 – Complete Short Notes & Exam Preparation Guide

Based on the NCERT Computer Science Class XI textbook chapter.

Python Tuples Dictionaries Programs Exam Preparation
verakworld.com
Chapter Focus: This chapter covers tuples, tuple operations, tuple methods and built-in functions, tuple assignment, nested tuples, tuple handling, dictionaries, dictionary operations, traversal, methods, built-in functions and dictionary manipulation.

📚 Chapter Overview

A tuple is an ordered sequence that can contain elements of different data types. Tuple elements are written inside round brackets and separated by commas. Like strings and lists, tuple elements can be accessed using index values.

A dictionary is a mapping data type in Python in which information is stored as key-value pairs. Keys are used to access the corresponding values.

📑 Table of Contents

10.1 Introduction to Tuples

verakworld.com

📌 Meaning of Tuple

Definition: A tuple is an ordered sequence of elements that may belong to different data types such as integer, float, string, list or even another tuple.

Key Points

  • Tuple elements are enclosed in round brackets ( ).
  • Elements are separated by commas.
  • Tuple elements have fixed positions.
  • Indexing starts from 0.
  • A tuple can contain different data types.
  • A tuple can contain a list or another tuple as an element.
Example – Tuple of integers
tuple1 = (1, 2, 3, 4, 5)
print(tuple1)
Example – Mixed data types
tuple2 = ('Economics', 87, 'Accountancy', 89.6)
print(tuple2)
Example – List inside tuple
tuple3 = (10, 20, 30, [40, 50])
print(tuple3)
Example – Tuple inside tuple
tuple4 = (1, 2, 3, 4, 5, (10, 20))
print(tuple4)
verakworld.com

📌 Single Element Tuple

If a tuple contains only one element, a comma must follow the element. Without the comma, Python treats the expression as an ordinary value.

Incorrect

tuple5 = (20)
print(type(tuple5))

Result: <class 'int'>

Correct

tuple5 = (20,)
print(type(tuple5))

Result: <class 'tuple'>

Exam Point: For a single-element tuple, the comma is essential: (20,).

Tuple Without Parentheses

seq = 1, 2, 3
print(type(seq))
print(seq)

A comma-separated sequence without parentheses is also treated as a tuple.

10.1.1 Accessing Elements in a Tuple

Tuple elements can be accessed using indexing and slicing, similar to lists and strings.

tuple1 = (2, 4, 6, 8, 10, 12)

print(tuple1[0])
print(tuple1[3])
print(tuple1[-1])
print(tuple1[1+4])
Indexing: Positive indexing starts at 0 from the left. Negative indexing starts at -1 from the right.
Important: Accessing an index outside the valid range causes IndexError.

10.1.2 Tuple is Immutable

Immutable: Once a tuple is created, its elements cannot be changed.
tuple1 = (1, 2, 3, 4, 5)
tuple1[4] = 10

An attempt to assign a new value to an existing tuple position results in a TypeError.

Exam Point: Lists are mutable whereas tuples are immutable.

Mutable Element Inside a Tuple

Although the tuple itself is immutable, an element inside it may be a mutable object such as a list.

tuple2 = (1, 2, 3, [8, 9])
tuple2[3][1] = 10

print(tuple2)

Here the list inside the tuple can be modified.

10.2.1 Concatenation

Concatenation: Joining two tuples using the + operator.
tuple1 = (1, 3, 5, 7, 9)
tuple2 = (2, 4, 6, 8, 10)

tuple3 = tuple1 + tuple2
print(tuple3)

Output:

(1, 3, 5, 7, 9, 2, 4, 6, 8, 10)

Extending a Tuple

tuple6 = (1, 2, 3, 4, 5)

tuple6 = tuple6 + (6,)
tuple6 = tuple6 + (7, 8, 9)

print(tuple6)
Concatenation creates a new tuple; it does not directly modify the original immutable tuple.

10.2.2 Repetition

Repetition operator: The * operator repeats the elements of a tuple.
tuple1 = ('Hello', 'World')
print(tuple1 * 3)

Output:

('Hello', 'World', 'Hello', 'World', 'Hello', 'World')
tuple2 = ('Hello',)
print(tuple2 * 4)

Output:

('Hello', 'Hello', 'Hello', 'Hello')
The first operand must be a tuple and the second operand must be an integer.

10.2.3 Membership

The in operator checks whether an element is present in a tuple. It returns True when present and False otherwise.

tuple1 = ('Red', 'Green', 'Blue')

print('Green' in tuple1)
print('Green' not in tuple1)

Output:

True
False
Operator Meaning
in Checks whether the element is present.
not in Checks whether the element is absent.

10.2.4 Slicing

Slicing can be applied to tuples in the same way as strings and lists.

tuple1 = (10, 20, 30, 40, 50, 60, 70, 80)
Expression Result Purpose
tuple1[2:7] (30, 40, 50, 60, 70) Elements from index 2 up to index 6
tuple1[0:len(tuple1)] Entire tuple All elements
tuple1[:5] (10, 20, 30, 40, 50) From beginning
tuple1[2:] (30, 40, 50, 60, 70, 80) From index 2 to end
tuple1[0:len(tuple1):2] (10, 30, 50, 70) Step size 2
tuple1[-6:-4] (30, 40) Negative indexing
tuple1[::-1] (80, 70, 60, 50, 40, 30, 20, 10) Reverse order
Remember: In slicing, the stop index is not included.

10.3 Tuple Methods and Built-in Functions

Function / Method Purpose Example
len() Returns the number of elements. len((10,20,30)) → 3
tuple() Creates a tuple from a sequence; without an argument it creates an empty tuple. tuple([1,2,3]) → (1,2,3)
count() Counts occurrences of an element. (10,20,10).count(10) → 2
index() Returns the index of the first occurrence. (10,20,30).index(30) → 2
sorted() Returns a new sorted list from tuple elements. sorted((3,1,2)) → [1,2,3]
min() Returns the smallest element. min((19,12,56)) → 12
max() Returns the largest element. max((19,12,56)) → 56
sum() Returns the sum of numeric elements. sum((10,20,30)) → 60
Exam Point: sorted() returns a new list; it does not change the original tuple.
verakworld.com

10.4 Tuple Assignment

Tuple Assignment: A tuple of variables on the left side of the assignment operator receives corresponding values from a tuple on the right side.
  • The number of variables should match the number of values.
  • Values are assigned according to their positions.
  • Expressions on the right side are evaluated before assignment.
(num1, num2) = (10, 20)

print(num1)
print(num2)
record = ("Pooja", 40, "CS")
(name, rollNo, subject) = record

print(name)
print(rollNo)
print(subject)
If the number of variables and values does not match, Python raises ValueError.
(a, b, c, d) = (5, 6, 8)

Result: Not enough values to unpack.

Assignment with Expressions

(num3, num4) = (10 + 5, 20 + 5)

After evaluation, num3 = 15 and num4 = 25.

verakworld.com

10.5 Nested Tuples

A nested tuple is a tuple present inside another tuple.

Nested tuples can be useful for storing records containing several related values, such as roll number, name and marks of students.

students = (
    (101, "Aman", 98),
    (102, "Geet", 95),
    (103, "Sahil", 87),
    (104, "Pawan", 79)
)

print("S_No  Roll_No  Name   Marks")

for i in range(len(students)):
    print(i + 1, students[i][0], students[i][1], students[i][2])
S_No Roll_No Name Marks
1101Aman98
2102Geet95
3103Sahil87
4104Pawan79
verakworld.com
verakworld.com

10.6 Tuple Handling

Program: Swapping Two Numbers Without a Temporary Variable

num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

print("\nNumbers before swapping:")
print("First Number:", num1)
print("Second Number:", num2)

(num1, num2) = (num2, num1)

print("\nNumbers after swapping:")
print("First Number:", num1)
print("Second Number:", num2)
Example: Enter the first number: 5 Enter the second number: 10 Numbers before swapping: First Number: 5 Second Number: 10 Numbers after swapping: First Number: 10 Second Number: 5
Escape characters: \t inserts horizontal tab space and \n inserts a new line.

Program: Area and Circumference of a Circle Using a Function

def circle(r):
    area = 3.14 * r * r
    circumference = 2 * 3.14 * r
    return (area, circumference)

radius = int(input("Enter radius of circle: "))

area, circumference = circle(radius)

print("Area of circle is:", area)
print("Circumference of circle is:", circumference)
Example: Enter radius of circle: 5 Area of circle is: 78.5 Circumference of circle is: 31.4
This demonstrates how a function can return more than one value using a tuple.

Program: Store n Numbers in a Tuple and Find Maximum & Minimum

numbers = tuple()

n = int(input("How many numbers do you want to enter?: "))

for i in range(n):
    num = int(input())
    numbers = numbers + (num,)

print("\nThe numbers in the tuple are:")
print(numbers)

print("The maximum number is:")
print(max(numbers))

print("The minimum number is:")
print(min(numbers))
Example: How many numbers do you want to enter?: 5 9 8 10 12 15 The numbers in the tuple are: (9, 8, 10, 12, 15) The maximum number is: 15 The minimum number is: 8

10.7 Introduction to Dictionaries

A dictionary is a mapping data type in Python that stores information as key-value pairs.
  • A key is separated from its value by a colon :.
  • Consecutive items are separated by commas.
  • Dictionary items are accessed using keys.
  • Keys must be unique.
  • Keys should be of an immutable type such as number, string or tuple.
  • Values can be repeated and can be of different data types.
Basic structure: {key1:value1, key2:value2, ...}

10.7.1 Creating a Dictionary

Empty Dictionary

dict1 = {}
print(dict1)

dict2 = dict()
print(dict2)

Dictionary with Data

dict3 = {
    "Mohan":95,
    "Ram":89,
    "Suhel":92,
    "Sangeeta":85
}

print(dict3)
Remember: Curly braces { } are used for dictionary creation, and each key-value pair is separated by a colon.

10.7.2 Accessing Items in a Dictionary

Unlike strings, lists and tuples, dictionary items are accessed using their keys rather than relative positions.

dict3 = {
    "Mohan":95,
    "Ram":89,
    "Suhel":92,
    "Sangeeta":85
}

print(dict3["Ram"])
print(dict3["Sangeeta"])

Output:

89
85
If a requested key is not present and direct indexing is used, Python raises KeyError.
print(dict3["Shyam"])

Result: KeyError.

10.8 Dictionaries are Mutable

Mutable means the contents of a dictionary can be changed after the dictionary has been created.

10.8.1 Adding a New Item

dict1 = {
    "Mohan":95,
    "Ram":89,
    "Suhel":92,
    "Sangeeta":85
}

dict1["Meena"] = 78

print(dict1)

10.8.2 Modifying an Existing Item

dict1["Suhel"] = 93.5
print(dict1)
A new key creates a new item. If the key already exists, assigning a new value modifies the existing item.

10.9 Dictionary Operations

10.9.1 Membership

The in operator checks whether a key is present in a dictionary.

dict1 = {
    "Mohan":95,
    "Ram":89,
    "Suhel":92,
    "Sangeeta":85
}

print("Suhel" in dict1)
print("Suhel" not in dict1)
True
False
In a dictionary, membership testing checks the keys.

10.10 Traversing a Dictionary

A dictionary can be traversed using a for loop.

Method 1 – Traverse Keys

dict1 = {
    "Mohan":95,
    "Ram":89,
    "Suhel":92,
    "Sangeeta":85
}

for key in dict1:
    print(key, ":", dict1[key])

Method 2 – Traverse Key-Value Pairs

for key, value in dict1.items():
    print(key, ":", value)
Exam Point: items() is useful when both key and value are required during traversal.

10.11 Dictionary Methods and Built-in Functions

Method / Function Purpose Typical Use
len() Returns number of key-value pairs. len(dict1)
dict() Creates a dictionary from key-value pairs. dict(pair1)
keys() Returns the dictionary keys. dict1.keys()
values() Returns the dictionary values. dict1.values()
items() Returns key-value pairs. dict1.items()
get() Returns the value corresponding to a key; returns None if the key is absent. dict1.get("Sangeeta")
update() Adds key-value pairs from another dictionary. dict1.update(dict2)
del Deletes a specified item or the complete dictionary. del dict1["Ram"]
clear() Removes all items from the dictionary. dict1.clear()

Important Examples

dict1 = {
    "Mohan":95,
    "Ram":89,
    "Suhel":92,
    "Sangeeta":85
}

print(len(dict1))
print(dict1.keys())
print(dict1.values())
print(dict1.items())

print(dict1.get("Sangeeta"))

dict2 = {"Sohan":79, "Geeta":89}
dict1.update(dict2)

del dict1["Ram"]

dict1.clear()

10.12 Manipulating Dictionaries

Dictionary manipulation includes creating, accessing, adding, modifying, searching and deleting key-value pairs.

Dictionary Example – ODD

ODD = {
    1:"One",
    3:"Three",
    5:"Five",
    7:"Seven",
    9:"Nine"
}

print(ODD.keys())
print(ODD.values())
print(ODD.items())
print(len(ODD))

print(7 in ODD)
print(2 in ODD)

print(ODD.get(9))

del ODD[9]
print(ODD)

💻 Important Python Programs

Program – Employee Names and Salaries

num = int(input("Enter the number of employees: "))

employee = {}
count = 1

while count <= num:
    name = input("Enter the name of the Employee: ")
    salary = int(input("Enter the salary: "))
    employee[name] = salary
    count += 1

print("\nEMPLOYEE_NAME\tSALARY")

for key in employee:
    print(key, "\t\t", employee[key])
Example output: EMPLOYEE_NAME SALARY Tarun 12000 Amina 34000 Joseph 24000 Rahul 30000 Zoya 25000

Program – Count Character Occurrences in a String

st = input("Enter a string: ")
dic = {}

for ch in st:
    if ch in dic:
        dic[ch] += 1
    else:
        dic[ch] = 1

for key in dic:
    print(key, ":", dic[key])
Example: Enter a string: HelloWorld H : 1 e : 1 l : 3 o : 2 W : 1 r : 1 d : 1

Program – Convert Digits into Number Names

def convert(num):
    numberNames = {
        0:"Zero", 1:"One", 2:"Two", 3:"Three", 4:"Four",
        5:"Five", 6:"Six", 7:"Seven", 8:"Eight", 9:"Nine"
    }

    result = ""

    for ch in num:
        key = int(ch)
        result = result + " " + numberNames[key]

    return result

num = input("Enter any number: ")
result = convert(num)

print("The number is:", num)
print("The numberName is:", result)
Example: Enter any number: 6512 The number is: 6512 The numberName is: Six Five One Two
verakworld.com

🖼️ Educational Visual – Railway Reservation System

The textbook presents a railway reservation system as an example of dividing a complex system into different subsystems. Each subsystem can be modelled using functions.

Trains’ information Days, timings, stations, classes and berths verakworld.com
Reservation information Booking open/close, available/waiting list, cancellation and refund verakworld.com
Information about staff Security and railway infrastructure verakworld.com
Food service verakworld.com
Billing service verakworld.com
Other details about railways verakworld.com
Figure: Railway reservation system
verakworld.com
Suggested image alt text: Railway reservation system showing train information, reservation information, staff and infrastructure, food service, billing service and other railway details.

📝 Exercise & Programming Problems

Tuple Output Questions

  1. For tuple1 = (23,1,45,67,45,9,55,45) and tuple2 = (100,200), find the output of: tuple1.index(45), tuple1.count(45), tuple1 + tuple2, len(tuple2), max(tuple1), min(tuple1), sum(tuple2) and sorted(tuple1).

Dictionary Output Questions

Consider:

stateCapital = {
    "AndhraPradesh":"Hyderabad",
    "Bihar":"Patna",
    "Maharashtra":"Mumbai",
    "Rajasthan":"Jaipur"
}

Find the output of:

  1. stateCapital.get("Bihar")
  2. stateCapital.keys()
  3. stateCapital.values()
  4. stateCapital.items()
  5. len(stateCapital)
  6. "Maharashtra" in stateCapital
  7. stateCapital.get("Assam")
  8. del stateCapital["Rajasthan"] followed by printing the dictionary

Conceptual Questions

  1. Explain why lists and tuples are ordered.
  2. Show with an example how a function can return more than one value.
  3. What advantages do tuples have over lists?
  4. When should a tuple or dictionary be used? Give suitable programming situations.
  5. Explain how a variable is rebuilt in the case of immutable data types.
  6. Why does len(tuple1) produce an error when tuple1 = (5)?

Programming Problems

  1. Read email IDs of n students and store them in a tuple. Create separate tuples for usernames and domain names.
  2. Input names of n students into a tuple and check whether a given student is present.
  3. Write a Python program to find the highest two values in a dictionary.
  4. Write a Python program to create a dictionary from a string by counting letters.
  5. Input friends’ names and phone numbers into a dictionary and perform display, add, delete, modify, search and sorted-display operations.

📊 Case Study-based Questions

SMIS Student Records

Design a program using a dictionary where roll number can act as the key and an immutable data type containing student name and percentage can act as the value.

  • Accept details of n students.
  • Search for a student using roll number.
  • Display the results of all students.
  • Find the topper.
  • Find subject toppers.

Banking System

  • Open a savings bank account.
  • Deposit money.
  • Withdraw money while considering minimum balance.
  • Take fixed-deposit amount and period and display maturity amount.
  • Use functions and appropriate data types.

Quiz System

  • Create an administrative user ID and password.
  • Add, modify and delete questions.
  • Register students before participation.
  • Allow category selection.
  • Display questions according to category.
  • Maintain and display the score.

Indian Heritage Sites System

Create a system for storing and searching information about Indian World Heritage Sites.

  • Site name
  • Location
  • District and State
  • Year built
  • Builder
  • Purpose
  • Website link, if available

Transportation Reservation System

Choose a mode of transportation and design a reservation system. A railway reservation system can be divided into subsystems such as train information, reservation information, staff/security/infrastructure, food service, billing service and other railway details.

❓ Short Questions & Answers

1. What is a tuple?
A tuple is an ordered sequence of elements enclosed in round brackets and separated by commas.
2. From which index does tuple indexing start?
Tuple indexing starts from index 0.
3. Is a tuple mutable?
No. A tuple is immutable.
4. How do you create a single-element tuple?
Place a comma after the element, for example (20,).
5. What is tuple concatenation?
It is joining two tuples using the + operator.
6. What is the use of the * operator with tuples?
It repeats tuple elements a specified number of times.
7. What does the in operator do?
It checks whether an element is present in a tuple or a key is present in a dictionary.
8. What is a nested tuple?
A tuple inside another tuple is called a nested tuple.
9. What is tuple assignment?
It assigns corresponding values of a tuple to a tuple of variables.
10. What is a dictionary?
A dictionary is a mapping data type that stores information as key-value pairs.
11. How are dictionary items accessed?
Dictionary items are accessed using keys.
12. Are dictionaries mutable?
Yes. Dictionary contents can be changed after creation.
13. What happens if a non-existing key is accessed using direct indexing?
Python raises a KeyError.
14. What does get() do?
It returns the value corresponding to a specified key and returns None if the key is absent.
15. What is the purpose of items()?
It provides the key-value pairs of a dictionary.
16. What does clear() do?
It removes all items from a dictionary.

📝 Important Questions for Exam

Very Short Answer

  1. Define tuple.
  2. What is immutability?
  3. Write the syntax for a single-element tuple.
  4. What is tuple concatenation?
  5. What is tuple repetition?
  6. What is tuple slicing?
  7. Define nested tuple.
  8. Define dictionary.
  9. What is a key-value pair?
  10. What is dictionary mutability?
  11. What is the use of keys()?
  12. What is the use of values()?
  13. What is the use of items()?
  14. What is the use of get()?
  15. What is the use of update()?

2-Mark / Short Answer Questions

  1. Explain why tuples are immutable with an example.
  2. Differentiate between list and tuple.
  3. Explain positive and negative indexing in tuples.
  4. Explain tuple concatenation with an example.
  5. Explain tuple repetition with an example.
  6. Explain tuple slicing with examples.
  7. Explain tuple assignment.
  8. Explain nested tuples.
  9. Explain how a tuple can be used to return multiple values from a function.
  10. Explain how dictionary items are accessed.
  11. Explain how to add and modify dictionary items.
  12. Explain dictionary traversal using a for loop.
  13. Differentiate between get() and direct dictionary indexing.
  14. Explain update(), del and clear().

Programming Questions

  1. Write a program to swap two numbers without using a temporary variable.
  2. Write a program to calculate area and circumference of a circle using a function returning a tuple.
  3. Write a program to input n numbers into a tuple and find maximum and minimum.
  4. Write a program to store employee names and salaries in a dictionary.
  5. Write a program to count character occurrences in a string using a dictionary.
  6. Write a function to convert digits into their corresponding number names.
  7. Write a program to find the highest two values in a dictionary.
  8. Write a program to create a dictionary from a string.

Difference Between List and Tuple

List Tuple
Mutable. Immutable.
Elements are commonly stored using square brackets. Elements are commonly stored using round brackets.
Elements can be changed after creation. Elements cannot be changed after creation.
Useful when data may need modification. Useful when data should remain unchanged.

Difference Between Tuple and Dictionary

Tuple Dictionary
Ordered sequence. Mapping of keys to values.
Elements are accessed using indices. Values are accessed using keys.
Tuple is immutable. Dictionary is mutable.
Uses round brackets for representation. Uses curly braces for representation.

⚡ Quick Revision

Tuple – Must Remember

  • Tuple is an ordered sequence.
  • Tuple elements are normally enclosed in round brackets.
  • Elements are separated by commas.
  • Indexing starts from 0.
  • Tuples are immutable.
  • A single-element tuple requires a comma.
  • + performs concatenation.
  • * performs repetition.
  • in and not in perform membership checking.
  • Slicing works with tuples.
  • Important functions/methods: len(), tuple(), count(), index(), sorted(), min(), max(), sum().
  • Nested tuple means a tuple inside another tuple.
  • Tuple assignment can assign several values at once.

Dictionary – Must Remember

  • Dictionary is a mapping data type.
  • Information is stored as key-value pairs.
  • Keys are separated from values using :.
  • Keys must be unique.
  • Keys act as the index for accessing values.
  • Keys should be immutable types.
  • Values can be repeated and can be of different data types.
  • Dictionaries are mutable.
  • in checks dictionary keys.
  • keys() returns keys.
  • values() returns values.
  • items() returns key-value pairs.
  • get() retrieves a value for a key.
  • update() adds key-value pairs from another dictionary.
  • del deletes an item or dictionary.
  • clear() removes all dictionary items.
Last-Minute Exam Tip: Focus especially on tuple immutability, single-element tuple syntax, indexing and slicing, tuple assignment, nested tuples, dictionary key-value structure, dictionary mutability, membership, traversal, dictionary methods and the important programs.

📌 Chapter Summary

Tuples are immutable ordered sequences whose elements can be accessed through indexing and slicing. They support operations such as concatenation, repetition and membership checking. Python provides several functions and methods for processing tuples.

Dictionaries store information as key-value pairs. Keys are unique and are used to access values. Dictionaries are mutable and can be modified by adding, changing or deleting items. They can also be traversed using loops and manipulated using methods such as keys(), values(), items(), get(), update() and clear().

Final Revision: Understand the difference between sequence-based access in tuples and key-based access in dictionaries, and practise the chapter programs and output-based questions.
© VerakWorld | Educational Notes
verakworld.com

📝 This article was researched and written by Venkatesh A, Founder of verakworld.com.

Leave a Comment