[go: up one dir, main page]

0% found this document useful (0 votes)
157 views18 pages

NPTEL Python Exam Preparation Guide

The document outlines a strategic blueprint for preparing for the NPTEL Python DSA examination, emphasizing the importance of understanding the exam format, scoring, and the relationship between weekly assignments and exam questions. It details the exam structure, prioritizes core topics for last-minute study, and identifies common question archetypes to enhance problem-solving strategies. Candidates are advised to focus on foundational concepts and efficient time management to maximize their scores and ensure eligibility for certification.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views18 pages

NPTEL Python Exam Preparation Guide

The document outlines a strategic blueprint for preparing for the NPTEL Python DSA examination, emphasizing the importance of understanding the exam format, scoring, and the relationship between weekly assignments and exam questions. It details the exam structure, prioritizes core topics for last-minute study, and identifies common question archetypes to enhance problem-solving strategies. Candidates are advised to focus on foundational concepts and efficient time management to maximize their scores and ensure eligibility for certification.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

A Strategic Blueprint for Excelling in the

NPTEL Python DSA Examination: The


Final 24-Hour Protocol

Deconstructing the Examination: Pattern, Scoring, and


Mindset

A successful outcome in any high-stakes examination begins not with rote memorization, but
with a deep, strategic understanding of the test itself. The NPTEL "Programming, Data
Structures and Algorithms using Python" exam is no exception. By deconstructing its format,
understanding the philosophy behind its questions, and clarifying the precise criteria for
certification, a candidate can move from a position of apprehension to one of confident
control. This section provides that foundational analysis, setting the stage for a targeted and
effective last-minute preparation protocol.

The Anatomy of the Exam: Format and Question Distribution

The final proctored examination is a comprehensive assessment conducted over a period of


three hours, with a total score of 100 marks.1 The paper is structured to contain a total of 40
questions. This structure results in a uniform weightage where each question, regardless of its
perceived difficulty, carries an average of 2.5 marks.3 This flat scoring landscape is a critical
strategic consideration; time spent on an overly complex problem yields the same potential
reward as time spent on a straightforward one, making efficient time allocation paramount.

The questions are delivered in a mixed format, designed to test different facets of a
candidate's understanding:
●​ Multiple Choice Questions (MCQs): These form the majority of the paper, with student
experiences indicating approximately 23 of the 40 questions fall into this category.3 They
typically feature a single correct answer and assess knowledge of definitions, properties
of algorithms, time complexities, or the output of simple code snippets.
●​ Fill-in-the-Blanks (FIB): These questions require the candidate to provide a specific
keyword, a numerical value, or a short piece of code to complete a given statement or
function.3 They test for precise knowledge of Python syntax, function names, or the
specific output of an algorithm.
●​ Integer Type Questions: This format demands a numerical answer, often related to
calculating the result of a function, counting the number of operations in an algorithm, or
stating a specific time complexity.3
●​ Comprehension-Based Sets: A particularly important format involves a single, more
substantial code snippet or a detailed problem description, which is then followed by two
to three related questions.3 These questions can be any mix of the above types (MCQ,
FIB, Integer). This format is designed to test a deeper, more integrated understanding of a
piece of code, requiring an initial investment of time to comprehend the provided context,
which then pays off across multiple questions.

Understanding the NPTEL Assessment Philosophy: The Centrality of


Assignments

The single most critical piece of intelligence for preparing for this examination is
understanding the direct and profound link between the weekly assignments and the final
exam questions. The NPTEL assessment philosophy for this introductory course is not to test
novel, unseen problem-solving skills but rather to rigorously verify that the candidate has
diligently engaged with the course material throughout the semester. The exam serves as a
confirmation of learning and effort.

This philosophy manifests in a clear and predictable pattern in the exam questions, as
consistently reported by former students across various platforms.2 The relationship between
assignments and exam questions can be categorized as follows:
●​ Direct Duplication: A small number of questions are taken verbatim—"word to
word"—from the weekly quizzes.3
●​ Structural Replication: A significantly larger portion of questions are structurally
identical to assignment problems but with altered values, variable names, or minor logical
twists.3 For example, a question asking to trace a sorting algorithm will use a different
initial list, or a function to find a bug will have a slightly different implementation, but the
core concept and the type of edge case being tested remain the same.
●​ Conceptual Alignment: The remaining questions are based on the fundamental
concepts taught in the video lectures. Since the weekly assignments are designed to test
these very same concepts, a thorough understanding of the assignments inherently
prepares a candidate for these questions as well.3

The consensus is overwhelming, with one student emphatically stating that the exam was
"90% from assignment".4 This makes the collected weekly assignments the highest-yield
revision material available, forming the cornerstone of any effective last-minute study plan.

Navigating the Certification Criteria

Understanding the certification criteria is crucial, as it is possible to achieve a passing total


score and still not be eligible for a certificate. The final score is typically a weighted average of
the internal assignment scores and the final proctored exam score. A common weighting is
25% for assignments and 75% for the proctored exam.2 Some iterations of the course have
also included a non-proctored programming exam, which would alter these weights.5

However, the most critical component is the minimum threshold requirement. A candidate will
be eligible for a certificate only if both of the following conditions are met:
1.​ Average Assignment Score >=10/25
2.​ Final Proctored Exam Score >=30/75

If either one of these criteria is not satisfied, a certificate will not be awarded, even if the final
combined score is 40 or higher.1 This dual-key system means that consistent performance
during the course is a prerequisite, and a strong performance on the final exam is mandatory.
For the purpose of this guide, it is assumed the candidate has met the assignment threshold
and the entire focus is on maximizing the proctored exam score to well above the 30/75
minimum.

The Core Syllabus: A Prioritized Topic-by-Topic


Analysis

With only 24 hours remaining, a comprehensive review of the entire eight-week syllabus is
impractical. The key to success lies in strategic prioritization, focusing intensely on topics that
are conceptually fundamental and have the highest probability of appearing on the exam. The
syllabus is cumulative; concepts from earlier weeks form the bedrock upon which later, more
complex topics are built. A shaky foundation in Python fundamentals will inevitably lead to an
inability to solve problems related to trees or dynamic programming. Therefore, this analysis
prioritizes topics based on both their foundational importance and their observed frequency
in past examinations.

Week 1-2: Python Fundamentals and Core Data Structures (High


Priority)

●​ Topics: Informal introduction to algorithms via GCD, Python installation and environment,
variables, fundamental data types (int, float, bool), control flow (if-elif-else, for/while
loops), functions, strings and string manipulation, lists, tuples, the Python memory model
(mutable vs. immutable values), and list operations like slicing.1
●​ Rationale for Priority: These topics are the essential syntax and semantics of the
Python language. They are the building blocks for every single subsequent week. A
significant portion of the exam, particularly the "find the error" and "predict the output"
archetypes, directly tests this foundational knowledge.8 Student feedback explicitly
highlights list and string manipulation as a major area of focus on the exam.3 Mastery
here is non-negotiable as it unlocks the ability to even attempt questions from later
weeks.
●​ Likely Question Types: MCQs on correct syntax, FIB questions requiring completion of a
loop or conditional, and comprehension questions based on code snippets that perform
complex list or string manipulations.

Week 3-4: Sorting, Searching, and Algorithmic Analysis (High Priority)

●​ Topics: Basic algorithmic analysis (input size, asymptotic complexity), Big O notation
(O()), arrays vs. lists, binary search, selection sort, insertion sort, merge sort, quicksort,
and properties of sorting algorithms like stability. This block also introduces dictionaries,
higher-order functions (map, filter), and list comprehensions.1
●​ Rationale for Priority: This is the classical core of any introductory algorithms course.
Questions on the time and space complexity of these fundamental algorithms are a
staple of computer science examinations. The ability to trace the execution of a sorting
algorithm on a small dataset or to understand the logic of a recursive algorithm like
merge sort is frequently tested.3 Dictionaries are one of Python's most powerful and
important data structures, and their usage is a recurring theme in programming
problems.3 Furthermore, the course's inclusion of Pythonic constructs like list
comprehensions indicates that idiomatic language usage is also a key learning objective
and thus a likely area for assessment.
●​ Likely Question Types: Integer Type questions asking for a specific complexity (e.g.,
"What is the worst-case time complexity of Quicksort?"), MCQs on algorithmic properties
(e.g., "Which of the following sorting algorithms is stable?"), and code completion
problems for the recursive parts of merge sort or quicksort.

Week 5-6: Advanced Python and Foundational Data Structures (High


Priority)

●​ Topics: Exception handling (try, except), standard input/output and file handling,
advanced string processing, backtracking (as exemplified by the N-Queens problem),
Python's scope rules (local, global, nonlocal), and the linear data structures: stacks,
queues, and heaps (priority queues).1
●​ Rationale for Priority: While some topics like file I/O may be less central, the data
structures introduced here are critically important. Stacks, queues, and heaps are
explicitly identified by past students as a major exam topic area.3 Conceptual questions
often revolve around selecting the appropriate data structure for a given problem (e.g.,
using a stack for "undo" functionality or implementing backtracking).3 Backtracking itself
is a powerful way to test a candidate's grasp of recursion in a practical context.
●​ Likely Question Types: Conceptual MCQs testing the use cases of stacks, queues, and
heaps. FIB questions to complete the logic within a recursive backtracking function.
Comprehension-based questions on code that simulates or implements these data
structures.

Week 7-8: Object-Oriented Programming and Advanced Algorithms


(High Priority)

●​ Topics: Abstract Data Types (ADTs), classes and objects in Python, implementation of
linked lists (find, insert, delete), binary search trees (BSTs) (find, insert, delete),
height-balanced trees (conceptual), memoization, and dynamic programming (e.g.,
longest common subsequence, matrix multiplication).1
●​ Rationale for Priority: This is the culmination of the course, bringing together Python's
object-oriented features with complex, non-linear data structures. Binary search trees
are a cornerstone topic and are frequently and heavily tested.3 Exam questions
commonly require candidates to complete methods within a​
Node or Tree class, trace traversals, or understand the properties that define a BST.3
Dynamic programming is a capstone topic; while complex implementations may be less
likely, questions on the core principle of memoization and its application to avoid
re-computation in recursive functions are highly probable.
●​ Likely Question Types: Code completion for methods within a class definition for a
linked list or BST.3 MCQs on the properties of BSTs (e.g., what constitutes a valid BST).
Comprehension questions involving recursive tree traversal functions.

The following table provides a consolidated, prioritized checklist for the final 24-hour revision
period.

Week Core Topics Key Concepts Revision Likely


& Algorithms Priority Question
Types

1-2 Python Basics Variables, High Syntax MCQs,


Control Flow, Code Output
Functions, Prediction,
Lists, Strings, List/String
Tuples, Manipulation
Mutability

3-4 Sorting & Big O Notation, High Complexity


Searching Binary Search, Analysis
Selection/Inser (Integer),
tion/Merge/Qui Algorithm
ck Sort, Properties
Dictionaries (MCQ),
Recursive
Code
Completion

5-6 Data Stacks, High Conceptual


Structures Queues, Use-Case
Heaps, (MCQ),
Backtracking, Recursive
Exception Logic (FIB),
Handling, Data Structure
Scope Simulation

7-8 Trees & DP Classes/Object High Class Method


s, Linked Lists, Completion
Binary Search (FIB), Tree
Trees (BST), Properties
Memoization, (MCQ),
Dynamic Recursive
Programming Traversal
Analysis

Mastering the Question Archetypes: From Syntax to


Semantics

Success in the NPTEL exam requires more than just passive knowledge of the topics; it
demands the ability to apply that knowledge to solve specific types of problems under time
pressure. The exam questions, while varied, tend to fall into a few recurring patterns or
"archetypes." By identifying these archetypes and developing a specific strategy for each, a
candidate can approach the paper with a structured, methodical mindset, recognizing
patterns and executing proven problem-solving techniques.

Archetype 1: Bug Identification ("Find the Error")

●​ Description: This archetype presents a Python function that appears correct at first
glance but contains a subtle logical or syntactical flaw. The task is to provide a specific
input that causes the function to produce an incorrect output or to identify the nature of
the error.
●​ Examples: An isprimebad(n) function that incorrectly handles non-prime squares of
primes (e.g., 4, 9, 25).8 A​
stablesortbad(l) function that correctly sorts by the primary key but fails to maintain the
relative order of elements with equal keys.9
●​ Strategy: The key to solving these problems is to think exclusively in terms of edge
cases. The bug will almost never be in the "average" case. Systematically test the
function mentally against a checklist of common edge cases:
○​ For numerical problems: Zero, one, negative numbers (if applicable), a small prime
number, a small composite number, a perfect square.
○​ For list-based problems: An empty list (``), a list with a single element, a list with all
identical elements, a list that is already sorted, a list that is sorted in reverse order.
○​ The error is almost always a failure to correctly initialize a variable, handle an empty
input, or manage an off-by-one error in a loop condition that only manifests at the
boundaries.

Archetype 2: Code Completion ("Fill in the Blanks")

●​ Description: This archetype provides an incomplete function, typically a recursive one,


with placeholders like AAA, BBB, or XXX.3 The candidate must supply the correct Python
expressions to make the function work as intended.
●​ Examples: Completing the base cases and recursive step for a function to find the
maximum value in a custom linked list (listmax).3 Defining the logic for a recursive sum
function on a linked list.3 Filling in the conditional logic for a function to find the minimum
of three numbers (​
min3).8
●​ Strategy: The approach must be bifurcated into analyzing the base case(s) and the
recursive step.
1.​ Identify the Base Case: For recursive functions on data structures, the base case is
the simplest possible input. For lists, this is often the empty list or a single-element
list. For trees and linked lists, it's the null or empty state (e.g., if self.value == None: or
if self.isleaf():).3 The code in the base case block should return a simple, immediate
answer (e.g., 0, 1, or the value of the single node).
2.​ Analyze the Recursive Step: The recursive step must solve a small part of the
problem and then call the same function on a smaller version of the input. For a
linked list, this is typically a call on self.next. For a binary tree, it's calls on self.left and
self.right. The task is to correctly combine the results of these recursive calls with the
current node's value (e.g., return(self.value + self.next.sum())). Tracing the function
call with a simple two- or three-element example on scratch paper can quickly reveal
the correct logic.

Archetype 3: Algorithmic Implementation ("Write the Function")

●​ Description: The candidate is given a problem described in natural language and must
write a complete, working Python function to solve it. These problems test the ability to
translate a specification into code.
●​ Examples: A function sumofsquares(n) to determine if n can be expressed as i2+j2.8 A
function​
subsequence(l1, l2) to check if a sorted list l1 is a subsequence of another sorted list l2.8
A function​
maxaggregate(l) to process a list of (player, score) tuples and find the player(s) with the
highest total score.8
●​ Strategy: A systematic, three-step approach is most effective:
1.​ Select the Right Data Structure: Carefully read the problem for keywords that hint
at the ideal data structure. The word "aggregate" in maxaggregate immediately
suggests grouping, for which a dictionary is the canonical Python tool. "Sorted lists"
in subsequence suggests an efficient two-pointer approach rather than nested
loops.
2.​ Decompose the Logic: Break the problem into a sequence of smaller, manageable
steps. For maxaggregate: (a) Initialize an empty dictionary. (b) Iterate through the
input list of tuples; for each tuple, update the corresponding player's score in the
dictionary. (c) After the loop, find the maximum value in the dictionary's values. (d)
Iterate through the dictionary again to find all keys (players) that match this
maximum value. (e) Return these keys in the specified format (e.g., a sorted list).
3.​ Code and Refine: Write the code for each small step. This modular approach makes
the problem less intimidating and easier to debug.

Archetype 4: Conceptual Puzzles (MCQs)

●​ Description: These are theoretical questions that test the fundamental properties and
appropriate use cases of data structures and algorithms, without requiring any coding.
●​ Examples: "What is the most general condition that guarantees that u & v == u | v?"
(where u and v are Python sets).3 The answer relies on understanding set theory: this is
only true if the sets are identical. "Which of the following data structures is best suited
to... find paths... and if any of the paths are blocked, we must be able to undo the last
step...?".3 The phrase "undo the last step" is a textbook description of the Last-In,
First-Out (LIFO) behavior of a stack, making it the correct answer.
●​ Strategy: These questions cannot be answered by last-minute cramming; they require
genuine understanding. The most effective preparation is to create a mental model for
each major data structure and algorithm during revision. For each one, ask and answer:
○​ What is its core principle? (e.g., Stack -> LIFO, Queue -> FIFO, Heap -> Priority Order,
BST -> Value-based Ordering).
○​ What are its primary strengths? (e.g., BST -> Fast search, insert, delete on average).
○​ What are its primary weaknesses? (e.g., BST -> Degenerates to a linked list with
sorted input).
○​ What is a classic real-world application? (e.g., Stack -> Function call stack, browser
history "back" button; Queue -> Print job spooling, breadth-first search).
The Final 24-Hour Strategy: A Tactical Blueprint for
Scoring 80+

With the examination looming, the focus must shift from broad learning to targeted,
high-impact revision. This section outlines a disciplined, hour-by-hour strategy designed to
maximize knowledge retention and optimize performance under pressure. The entire plan is
built upon the single most important principle identified in the analysis: the exam is a direct
reflection of the weekly assignments.

The Golden Rule: Prioritize Assignments Above All Else

The foundation of this 24-hour protocol is the strategic decision to focus almost exclusively
on the course assignments. As established, the final exam questions are overwhelmingly
derived from, or structurally identical to, the weekly quizzes and programming problems.3
Therefore, mastering the assignments is the most direct and efficient path to mastering the
exam. The first step is to gather all eight weekly assignments and their corresponding
solutions. These documents are the primary study materials.

The 8-Hour Revision Cycle

This cycle is designed to be an intense, focused block of study that can be repeated if time
permits. It emphasizes active recall over passive reading, a technique proven to be far more
effective for long-term retention and deep understanding.2
●​ Hours 1-4: Active Recall with Assignments (Weeks 1-4)
1.​ Setup: Take a blank sheet of paper and the assignment questions for Week 1.
2.​ Solve, Don't Read: For each question, cover the solution and attempt to solve it
from scratch.
3.​ Articulate Reasoning: For MCQs, don't just pick an answer. Verbally or mentally
explain why that option is correct and, just as importantly, why the other options are
incorrect. This solidifies conceptual understanding. For programming or bug-finding
questions, write out the logic or the full code on paper.
4.​ Analyze and Correct: Only after making a genuine attempt, compare the result with
the official solution. If there is a discrepancy, do not simply note the correct answer
and move on. Spend the next 5-10 minutes deeply analyzing the correct logic. Why
did the proposed solution work? Where did the initial attempt go wrong? This
process of identifying and correcting misconceptions is where true learning occurs.
5.​ Repeat: Follow this exact process for the assignments from Weeks 2, 3, and 4. This
covers the foundational topics of Python basics, sorting, searching, and complexity
analysis.
●​ Hours 5-8: Active Recall with Assignments (Weeks 5-8)
1.​ Continue the Process: Apply the same active recall methodology to the
assignments from Weeks 5 through 8.
2.​ Emphasize Complexity: This block covers more complex topics like stacks, queues,
heaps, backtracking, linked lists, and binary search trees. Pay special attention to
recursive solutions. When analyzing a recursive function, trace its execution on paper
for a simple case to ensure a full grasp of its flow, including the base cases and the
recursive calls.

The Final Review (Last 2-3 Hours Before Sleep)

●​ Pattern Reinforcement: Quickly read through all assignment questions and their
solutions one last time. The goal here is not to solve them again but to refresh the
patterns, logic, and syntax in short-term memory. This rapid pass helps consolidate the
day's intensive revision.
●​ Cheatsheet Drill: Review a high-density, one-page cheatsheet (such as the one
provided in the Appendix). Focus on memorizing critical, easily forgotten facts like the
time complexities of sorting algorithms and the core operations of data structures.
●​ Cease New Learning: It is critical to avoid the temptation to learn a new topic from
scratch at this stage. This is a low-yield activity that often induces panic and can interfere
with the knowledge that has already been consolidated. The focus must remain on
strengthening existing knowledge.

In-Exam Tactics: Maximizing Your Score in 180 Minutes

A solid knowledge base must be paired with intelligent test-taking strategy to achieve a top
score.
●​ The Two-Pass Approach:
○​ Pass 1 (First 60-75 minutes): Begin at question 1 and proceed through the entire
paper, answering only the questions for which the solution is immediately obvious
and confidence is 100%. If a question requires more than a minute or two of thought,
mark it and skip it immediately. The objective is to rapidly secure a substantial base
score (e.g., 40-50 marks) and build psychological momentum.
○​ Pass 2 (Remaining 105-120 minutes): With a solid score already secured, return to
the beginning and work through the marked, more challenging questions. The
pressure is now significantly reduced, allowing for clearer, more focused thinking.
This approach mitigates the risk of getting stuck on a difficult problem early on and
running out of time for easier questions at the end of the paper.
●​ Managing Comprehension Sets: When a question set based on a single code snippet is
encountered, it is efficient to invest the necessary time upfront to fully understand the
provided code's functionality, variables, and logic. This initial investment will enable rapid
and accurate answers to all 2-3 associated questions.
●​ Educated Guessing: For difficult MCQs where the answer is not known, apply the
process of elimination.2 It is often possible to identify one or two options as clearly
incorrect or illogical. This dramatically improves the probability of a correct guess from
25% to 50% or even 100%.

Essential Resources and Common Pitfalls

To execute the final 24-hour strategy effectively, it is essential to have the right resources at
hand and to be acutely aware of the common mistakes that the exam is designed to test. This
section provides a curated list of high-value resources and a "pre-mortem" analysis of
frequent Python errors that often form the basis of exam questions.

High-Value Revision Resources

The revision process should be focused and efficient, avoiding the distraction of low-quality
or irrelevant material. The following resources are categorized by priority.
●​ Primary Resource (Mandatory):
○​ Official NPTEL Weekly Assignments: The complete set of all 8 weekly assignments,
including both quizzes and programming problems, from the official course portal.
This is the single most important resource.
●​ Secondary Resource (Highly Recommended):
○​ GitHub Repositories: Public repositories containing solutions to past iterations of
the course's assignments. These are invaluable for verifying self-solved problems
and for understanding the logic behind questions where one is stuck. The repository
by user arwazkhan189 is a documented example of such a resource.10
●​ Tertiary Resources (For Specific Doubts):
○​ YouTube Explainer Videos: Channels that specialize in solving or explaining NPTEL
course content. Channels such as "Deep Codec Guru" and "Swayam Solver" have
been noted by students.11 These should be used not for a general review, but to
clarify doubts on a specific, particularly difficult problem or concept.

Pre-Mortem: Avoiding Common Python Pitfalls Tested in the Exam

A significant portion of an introductory programming exam is dedicated to testing a


candidate's understanding of the language's nuances and common points of confusion. The
"Bug Identification" and "Predict the Output" question archetypes are perfect vehicles for
this. By anticipating these traps, a candidate can turn potential weaknesses into strengths.
The exam will likely test the following common Python pitfalls:
●​ Mutability Errors: A classic error is the misuse of mutable data types (lists, dictionaries)
where immutable ones (tuples, strings) are required. The most common example is
attempting to use a list as a dictionary key, which will raise a TypeError because keys
must be hashable.13 An exam question might present such code and ask what error it
produces.
●​ Scope Errors: Python's rules for variable scope (local vs. global) can be tricky. A function
might inadvertently create a new local variable instead of modifying a global one, or a
variable might be referenced before it is assigned a value within a local scope, leading to
an UnboundLocalError.14 Questions testing this might involve predicting the final value of
a global variable after a function call.
●​ Off-by-One and Indexing Errors: A very common beginner mistake is to modify a list
while iterating over it. Removing elements from a list while looping through it using
indices will cause some elements to be skipped and can lead to an IndexError.13 A
question might present such a loop and ask for the final state of the list.
●​ Syntactical Errors: Simple syntax mistakes are a frequent source of errors. The exam
may test these by presenting code with a missing colon (:) after a def, if, or for statement
and asking to identify the SyntaxError.13 Another classic is the confusion between the
assignment operator (​
=) and the equality comparison operator (==) within a conditional statement.13
●​ Type Errors: Python is strongly typed, and operations between incompatible types will
raise a TypeError. A common example is attempting to concatenate a string with an
integer without explicitly converting the integer using the str() function.13 The exam might
ask for the output of such an operation, with one of the options being "TypeError".
Appendix: High-Impact Revision Tools

A.1. Curated Practice Problem Set

This set of problems is selected from the research material as being highly representative of
the exam's style and content. Attempting these under timed conditions can serve as a final
mock test.
1.​ Bug Identification: Here is a function isprimebad that takes a positive integer as input
and returns True if the number is prime and False otherwise. There is an error in this
function. Provide an input n, which is a positive integer, for which isprimebad produces
an incorrect output. (Based on 8)
2.​ Code Completion (Recursion/Trees): Consider a Node class for a binary tree with
self.left, self.right, isempty(), and isleaf() methods. Complete the function foo(self) below
to count the number of leaves in the tree.​
Python​
def foo(self):​
if self.isempty():​
return(AAA)​
elif self.isleaf():​
return(BBB)​
else:​
return(CCC)​

(Based on 3)
3.​ Algorithmic Implementation (Dictionaries): Write a Python function maxaggregate(l)
that takes a list of (name, score) tuples. It should compute the total score for each name
and return a list of the names of the player(s) with the highest total score, sorted
alphabetically. For example,
maxaggregate([('Kohli',73),('Ashwin',33),('Kohli',7),('Pujara',122),('Ashwin',90)]) should
return ['Ashwin']. (Based on 8)
4.​ Conceptual Puzzle (Data Structures): Which of the following data structures is best
suited for a task that involves processing items in the order they were received, such as a
printer queue? (a) Stack (b) Queue (c) Heap (d) Hash Table. (Based on 3 logic)
5.​ Algorithmic Implementation (Logic/Loops): A positive integer n is a "sum of squares"
if n=i2+j2 for integers i≥1 and j≥1. Write a Python function sumofsquares(n) that takes a
positive integer n and returns True if it is a sum of squares, and False otherwise. (Based
on 8)

A.2. The One-Page "Pre-Exam" Cheatsheet

This cheatsheet is designed for rapid, last-minute review to activate short-term memory of
critical facts.

NPTEL Python DSA: Final Review Cheatsheet

1. Time Complexities of Sorting Algorithms

Algorithm Best Case Average Worst Case Space Stable?


Case Complexity
(Worst)

Selection O(n2) O(n2) O(n2) O(1) No


Sort

Insertion O(n) O(n2) O(n2) O(1) Yes


Sort

Bubble O(n) O(n2) O(n2) O(1) Yes


Sort

Merge Sort O(nlogn) O(nlogn) O(nlogn) O(n) Yes

Quicksort O(nlogn) O(nlogn) O(n2) O(logn) No

Heapsort O(nlogn) O(nlogn) O(nlogn) O(1) No

2. Core Data Structure Operations & Complexities

Data Structure Operation Average Time Worst Time Key Principle

List (Python) append O(1) O(1) Dynamic Array


insert(0, val) O(n) O(n)

pop() O(1) O(1)

pop(0) O(n) O(n)

__getitem__ O(1) O(1)

Stack push / pop O(1) O(1) LIFO (Last-In,


First-Out)

Queue enqueue / O(1) O(1) FIFO (First-In,


dequeue First-Out)

Dictionary get / set / del O(1) O(n) Key-Value,


Hash Table

Heap insert / O(logn) O(logn) Priority Order


delete-min

Binary Search search / insert O(logn) O(n) Ordered


Tree / delete Structure

3. Key Python Syntax & Concepts


●​ List Comprehension: squares = [x**2 for x in range(10) if x % 2 == 0]
●​ Dictionary Creation: my_dict = {'key1': 'value1', 'key2': 123}
●​ Exception Handling:​
Python​
try:​
result = 10 / 0​
except ZeroDivisionError:​
print("Cannot divide by zero")​
finally:​
print("Execution finished")​

●​ Classes and Objects:​


Python​
class Node:​
def __init__(self, value):​
self.value = value​
self.next = None​

●​ Mutability:
○​ Immutable: int, float, str, tuple, bool. Values cannot be changed in place.
○​ Mutable: list, dict, set. Values can be changed in place.
●​ Recursion Template (e.g., for a list):​
Python​
def recursive_func(my_list):​
if len(my_list) == 0: # Base case​
return base_value​
else: # Recursive step​
return combine(my_list, recursive_func(my_list[1:]))​

Works cited

1.​ Programming, Data Structures And Algorithms Using Python - Course - Swayam -
NPTEL, accessed on September 17, 2025,
https://onlinecourses.nptel.ac.in/noc25_cs59/preview
2.​ Data Structures and Algorithms Using Python - an NPTEL(Swayam ..., accessed on
September 17, 2025,
https://www.geeksforgeeks.org/competitive-exam-experiences/data-structures-
and-algorithms-using-python-an-nptelswayam-exam-experience/
3.​ How was the proctored exam for the NPTEL 'Programming, Data ..., accessed on
September 17, 2025,
https://www.quora.com/How-was-the-proctored-exam-for-the-NPTEL-Program
ming-Data-Structures-and-Algorithms-Using-Python-course-What-were-the-qu
estion-types
4.​ NPTEL exam in 1 week, haven't studied anything. Can't afford to fail ..., accessed
on September 17, 2025,
https://www.reddit.com/r/developersIndia/comments/1c29yl1/nptel_exam_in_1_we
ek_havent_studied_anything_cant/
5.​ Programming, Data Structures And Algorithms Using Python - - Announcements,
accessed on September 17, 2025,
https://onlinecourses.nptel.ac.in/noc21_cs67/announcements
6.​ Programming, Data Structures And Algorithms Using Python - Course - Swayam -
NPTEL, accessed on September 17, 2025,
https://onlinecourses.nptel.ac.in/noc22_cs26/preview
7.​ Programming, Data Structures and Algorithms using Python - NPTEL, accessed
on September 17, 2025, https://nptel.ac.in/courses/106106145
8.​ Programming, Data Structures And Algorithms Using Python online exam session
1 · GitHub, accessed on September 17, 2025,
https://gist.github.com/smriti1313/33e0878c3c3b6bc93363480ba42b5c28
9.​ ONLINE TEST 2-5 PM | Solution for NPTEL Programming, Data Structures and
Algorithms using Python | Hackademic, accessed on September 17, 2025,
https://hackademic.co.in/online-test-2-5-pm-solution-for-nptel-programming-da
ta-structures-and-algorithms-using-python/
10.​arwazkhan189/NPTEL---Programming-Data-Structures ... - GitHub, accessed on
September 17, 2025,
https://github.com/arwazkhan189/NPTEL---Programming-Data-Structures-And-A
lgorithms-Using-Python
11.​ NPTEL Programming Data Structure and Algorithm Using Python Final Exam
Complete Crack Guide 2 Days - YouTube, accessed on September 17, 2025,
https://www.youtube.com/watch?v=Ayl4NCha2GY
12.​NPTEL | Programming, Data Structures and Algorithms using Python | July 2024 -
YouTube, accessed on September 17, 2025,
https://www.youtube.com/playlist?list=PLK07Q-reafmaYZ6dES3wwux1brJ0nLyaB
13.​10 Common Python Mistakes in 2025 | Are You Making Them?, accessed on
September 17, 2025, https://hackr.io/blog/common-python-mistakes
14.​15 Common Errors in Python and How to Fix Them | Better Stack Community,
accessed on September 17, 2025,
https://betterstack.com/community/guides/scaling-python/python-errors/
15.​8. Errors and Exceptions — Python 3.13.7 documentation, accessed on September
17, 2025, https://docs.python.org/3/tutorial/errors.html
16.​10 Mistakes Newbie Python Developers Make | by Huzaifa Zahoor - Medium,
accessed on September 17, 2025,
https://medium.com/@huzaifazahoor654/10-mistakes-newbie-python-developer
s-make-aaa4d6ca3b7d

You might also like