Question 1
Consider the following Python functions:
Given that mystery(8) == 4, what should replace the missing line?
—
—
—
—

The IIT Madras BS Programming in Python (Python) End Term paper sat on 10 May 2026, in the January 2026 term, set 3: 20 questions for 52 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Consider the following Python functions:
Given that mystery(8) == 4, what should replace the missing line?
—
—
—
—
Correct answer
—
Consider the following code:
What is the output?
—
—
—
—
Correct answer
—
Consider the following Python function.
Which of the following inputs will produce the output 'b'?
—
—
—
—
Correct answer
—
What does the following code compute?
85
105
91
36
Correct answer
91
Consider the snippets: Code-1
Code-2
Code-3
Which statement is correct?
Only Code-1 throws an error
Only Code-2 throws an error
Only Code-3 throws an error
None throw an error
Correct answer
Only Code-3 throws an error
What is the output of the following snippet of code?




Correct answer

What is the output?
The output contains
The output contains
p == 5
q == "Z"
p == "F"
q == "F"
The finally block executes only when an exception occurs
Correct answers
The output contains
p == "F"
q == "F"
is a list of tuples . Select all correct snippets that produce a list of names scoring strictly above 80, sorted by score descending.




Correct answers


Consider the following snippet of code:
Select all that apply. Note • If a value is passed to , it reads that many number of characters from the current position of the file pointer. • The method moves the position of the file pointer to the given number of chars after the start of the file.
The first line of the output is .
The second line of the output is .
The second line of the output is .
There are 5 lines in the output.
The output contains empty lines.
Correct answers
The first line of the output is .
The second line of the output is .
There are 5 lines in the output.
Consider the following Python code snippet:
What is the output of the program?
A written answer, not marked automatically.
What is printed?
A written answer, not marked automatically.
Fill in the blank with the missing expression so that the following conditions hold:
A written answer, not marked automatically.
What is the output?
A written answer, not marked automatically.
What is the output? Note : The function divmod(a, b) gives two values: (quotient : x // 10 , remainder : x % 10) for example: divmod(27, 10) gives (2, 7)
A written answer, not marked automatically.
Based on the above data, answer the given subquestions.
What is printed by ?
4
No output
7
8
Correct answer
No output
Based on the above data, answer the given subquestions.
What is printed as the output?
—
—
—
—
Correct answer
—
Based on the above data, answer the given subquestions.
What is the value of ?
1
2
3
8
Correct answer
2
Based on the above data, answer the given subquestions.
What is the value of ?
8
10
11
12
Correct answer
10
Based on the above data, answer the given subquestions.
A written answer, not marked automatically.
Based on the above data, answer the given subquestions.
A written answer, not marked automatically.