12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
([Link] ([Link]
kavikaushik_23ec106@[Link]
NPTEL ([Link] » The Joy of Computing using Python (course)
Course Week 5: Assignment 5
outline The due date for submitting this assignment has passed.
Due on 2026-02-25, 23:59 IST.
About
NPTEL ()
Assignment submitted on 2026-02-16, 15:20 IST
How does an Dilrez Builds a Smart Student Record System
NPTEL
online Dilrez is a teaching assistant who is asked to create a Smart Student Record System for a
course small institute.
work? () The system must store, update, analyze, and report student data efficiently.
Week 1 () To achieve this, Dilrez chooses Python Dictionaries because:
Each student has a unique roll number
Week 2 () Each roll number maps to multiple details
Data needs to be updated, searched, and processed quickly
Week 3 ()
What Is a Dictionary? (Key–Value Mapping)
week 4 ()
A dictionary stores data in key : value form.
Week 5 ()
Introduction to
Dictionaries
(unit?
unit=104&less
on=105)
Speech to Text 2. Accessing Dictionary Data
: No need to
write 01 (unit?
unit=104&less
on=106)
[Link] 1/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
Speech to Text .get() is safer because it does not cause an error if the key is missing.
: No need to
write 02 (unit? 3. Adding & Updating Data in a Dictionary
unit=104&less
on=107) Dilrez now wants to add marks.
Speech to Text
: No need to
write 03 (unit?
unit=104&less
on=108)
Monte Hall : 3 4. Dictionary of Lists (One Student, Multiple Scores)
doors and a
twist 01 (unit? Each student has marks in multiple tests.
unit=104&less
on=109)
Monte Hall : 3
doors and a
twist 02 (unit?
unit=104&less
on=110)
Rock, Paper
and Scissor :
Processing the list inside a dictionary
Cheating not
allowed !! 01
(unit?
unit=104&less
on=111)
Rock, Paper
5. Dictionary of Dictionaries (Structured Records)
and Scissor :
Cheating not
Now Dilrez stores multiple students.
allowed !! 02
(unit?
unit=104&less
on=112)
Rock, Paper
and Scissor :
Cheating not
allowed !! 03
(unit?
unit=104&less Accessing nested data
on=113)
Rock, Paper
and Scissor :
Cheating not
allowed !! 04
(unit?
unit=104&less This structure is ideal for databases, JSON, APIs.
on=114)
Sorting and 6. List of Dictionaries (Row-Wise Data)
Searching : 20
questions Sometimes data comes row-by-row (like Excel).
[Link] 2/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
game 01 (unit?
unit=104&less
on=115)
Sorting and
Searching : 20
questions
game 02 (unit?
unit=104&less
on=116) Searching in list of dictionaries
Sorting and
Searching : 20
questions
game 03 (unit?
unit=104&less
on=117)
Sorting and
7. Looping Through Dictionaries
Searching : 20
questions
game 04 (unit? Keys only
unit=104&less
on=118)
Sorting and
Searching : 20
questions
game 05 (unit? Values only
unit=104&less
on=119)
Sorting and
Searching : 20
questions
game 06 (unit?
unit=104&less Key–Value pairs
on=120)
Sorting and
Searching : 20
questions
game 07 (unit?
unit=104&less Complete Mini Program
on=121)
Sorting and
Searching : 20
questions
game 08 (unit?
unit=104&less
on=122)
Week 5
Feedback
Form: The Joy
of Computing
using Python
(unit?
[Link] 3/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
unit=104&less
on=123)
Week 5 :
Programming
Assignment 1
(/noc26_cs84/
progassignme
nt?name=623)
Week 5 :
Programming
Assignment 2
(/noc26_cs84/
progassignme
nt?name=624)
Week 5 :
Programming 1) Dilrez wants to extract the first test score of Riya from a nested student record. 1 point
Assignment 3 What will be printed?
(/noc26_cs84/
progassignme
nt?name=625)
Quiz: Week 5:
Assignment 5
(assessment?
name=632)
Week 6 () 92
79
Week 7 ()
88
Week 8 () Error
Yes, the answer is correct.
Week 9 () Score: 1
Accepted Answers:
Week 10 () 88
Week 11 () 2) A new test score is added for Kabir. How many marks does Kabir finally have? 1 point
Week 12 ()
Text
Transcripts ()
Download
Videos ()
3
85
4
Error
Yes, the answer is correct.
[Link] 4/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
Score: 1
Accepted Answers:
4
3) Dilrez modifies a list stored inside a dictionary and then reuses the same reference. 1 point
What is printed?
[1, 2, 3]
[1, 2, 3, 4]
Error
[4]
Yes, the answer is correct.
Score: 1
Accepted Answers:
[1, 2, 3, 4]
4) Dilrez slices a list obtained from a dictionary and modifies the [Link] happens 1 point
to the original list?
[10, 20, 30, 40]
[10, 20, 99]
Error
[10, 20]
Yes, the answer is correct.
Score: 1
Accepted Answers:
[10, 20, 30, 40]
5) A function reassigns a dictionary parameter instead of mutating it. What value is 1 point
printed?
[Link] 5/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
10
100
None
Error
Yes, the answer is correct.
Score: 1
Accepted Answers:
10
6) Dilrez modifies a dictionary while iterating over its keys without creating a copy. 1 point
What happens when the code runs?
2
3
1
Runtime Error
Yes, the answer is correct.
Score: 1
Accepted Answers:
Runtime Error
7) Dilrez draws a bar graph to compare students fairly, even though they have 1 point
attempted a different number of tests. Which student’s bar will be the tallest?
Kabir
Ayaan
Riya
All bars will be equal
Yes, the answer is correct.
Score: 1
Accepted Answers:
Riya
[Link] 6/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
8) Dilrez plots a line graph showing performance of each test across all students. 1 point
Which test appears as the highest point?
Test 2
Test 1
Test 3
All tests overlap
Yes, the answer is correct.
Score: 1
Accepted Answers:
Test 3
9) Dilrez creates a pie chart showing pass vs fail distribution (pass ≥ 60). Which 1 point
section occupies more area?
Equal distribution
Pass section
Cannot be inferred
Fail section
Yes, the answer is correct.
Score: 1
Accepted Answers:
Pass section
10) Dilrez plots a cumulative trend graph of weekly progress. What overall shape will 1 point
the graph show?
Decreasing trend
[Link] 7/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
Flat line
Random fluctuations
Increasing trend
Yes, the answer is correct.
Score: 1
Accepted Answers:
Increasing trend
Searching for a Book ID in a Digital Library
A college library maintains a sorted list of book IDs.
Each time a student requests a book, the system must search for the book ID and also
measure how many checks (iterations) were needed to find it.
Two interns, Aarav and Neel, suggest two different approaches:
Aarav uses Linear Search
Neel uses Binary Search
The librarian wants to understand:
1. How each method works
2. How many iterations each method takes
3. Which method is more efficient and why
Part 1: Linear Search Case Study
Idea Behind Linear Search
Linear search works exactly like checking books one by one on a shelf, starting from the first
book until the required one is found.
No assumptions about sorting
Simple and intuitive
Works for any list
Sample Scenario
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
x=7
[Link] 8/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
We are searching for the element 7 in the list:
The algorithm starts from the first index (0) and moves forward one element at a time.
1. First iteration
The element at index 0 is 1.
It does not match 7, so the counter increases and the search continues.
2. Second iteration
The element at index 1 is 2.
Still not a [Link] algorithm moves ahead.
3. Third iteration
The element at index 2 is 3.
Again, no match.
4. Fourth iteration
The element at index 3 is 4.
The search continues.
5. Fifth iteration
The element at index 4 is 5.
No match yet. 6.
6. Sixth iteration
The element at index 5 is 6.
The algorithm proceeds further.
7. Seventh iteration
The element at index 6 is 7.
This time, the element matches the target.
Why the iteration count is 7
The counter increases before checking each element, and the algorithm must visit every
position from index 0 to index 6.
So, even though the element is at position 6, it takes 7 checks to find it.
Part 2: Binary Search Case Study
Idea Behind Binary Search
Binary search is like opening a dictionary:
You don’t start from page 1
You open the middle, then decide left or right
Important Requirement:
The list must be sorted
[Link] 9/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
Same Scenario, Different Strategy
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
x=7
Binary search works by eliminating half of the list after every comparison.
1. First iteration
The middle element of the list is calculated.
The value at the middle position is 5.
Since 7 is greater than 5, the algorithm ignores the left half and continues with the right half.
2. Second iteration
A new middle is calculated in the remaining right portion.
The value now checked is 8.
Since 7 is smaller than 8, the algorithm moves left.
3. Third iteration
The middle is recalculated again.
The value checked is 6.
Since 7 is greater than 6, the algorithm shifts right.
4. Fourth iteration
The middle position now contains 7.
The target is found, and the search stops.
Why the iteration count is only 4
Each step removes half of the remaining elements, drastically reducing the number of
comparisons.
This is why binary search grows logarithmically and is much faster for large datasets.
11) A list contains 10 sorted elements. The target element is located at index 6. 1 point
Using the linear search code from the case study, how many iterations will be counted?
10
[Link] 10/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
6
7
5
Yes, the answer is correct.
Score: 1
Accepted Answers:
7
12) In the binary search implementation, what primarily causes the number of iterations 1 point
to reduce compared to linear search?
The use of a flag variable
The loop runs fewer times due to index jumps
The list length is fixed
Elements are compared sequentially
Yes, the answer is correct.
Score: 1
Accepted Answers:
The loop runs fewer times due to index jumps
13) If the searched element is not present in the list of 10 elements,which statement is 1 point
true regarding the iteration count?
Linear search will stop after half the list
Binary search will always run exactly 10 times
Binary search cannot handle missing elements
Linear search will check all elements
Yes, the answer is correct.
Score: 1
Accepted Answers:
Linear search will check all elements
14) If the number of elements increases from 10 to 1,000, which graph best represents 1 point
the growth of iterations for binary search?
A slowly rising curve
A flat horizontal line
A zig-zag pattern
A steep straight line
Yes, the answer is correct.
Score: 1
Accepted Answers:
A slowly rising curve
15) In the binary search code, what would happen if the list were unsorted but the 1 point
same logic was applied?
The algorithm would still work but slower
The iteration count would double
[Link] 11/12
12/04/2026, 23:13 The Joy of Computing using Python - - Unit 8 - Week 5
Python would raise a runtime error
The element may not be found even if present
Yes, the answer is correct.
Score: 1
Accepted Answers:
The element may not be found even if present
[Link] 12/12