Question 1
Consider the following recursive functions:
Which of the following function calls returns the last digit of 5! ?
—
—
—
—

The IIT Madras BS Programming in Python (Python) End Term paper sat on 10 May 2026, in the January 2026 term, set 1: 68 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 recursive functions:
Which of the following function calls returns the last digit of 5! ?
—
—
—
—
Correct answer
—
Consider the following code snippet:
For what values as input the output generated by the above code snippet does not print A.
x = 10 and y = 25
x = 6 and y = 20
x = 12 and y = 15
x = 15 and y = 16
Correct answer
x = 12 and y = 15
Consider the following code snippet:
For what values as input the output generated by the above code snippet does not print A.
x = 10 and y = 25
x = 6 and y = 20
x = 12 and y = 15
x = 15 and y = 16
Correct answer
x = 12 and y = 15
Consider the following recursive functions:
Which of the following function calls returns the last digit of 5! ?
—
—
—
—
Correct answer
—
Consider the following class:
What are the values of , , and respectively?
1, False, 300
2, False, 500
2, True, 300
3, True, 300
Correct answer
2, True, 300
Which of the following code snippets print the first 100 powers of 3, one on each line. The line should have the value of . The output has 100 lines in total. The first five lines look like this:




Correct answer

Which of the following code snippets print the first 100 powers of 3, one on each line. The line should have the value of . The output has 100 lines in total. The first five lines look like this:




Correct answer

Consider the following class:
What are the values of , , and respectively?
1, False, 300
2, False, 500
2, True, 300
3, True, 300
Correct answer
2, True, 300
What will be the output of the following Python code?




Correct answer

What will be the output of the following code snippet?
—
—
—
—
Correct answer
—
What will be the output of the following code snippet?
—
—
—
—
Correct answer
—
What will be the output of the following Python code?




Correct answer

What is the output of the following snippet of code?




Correct answer

What is the output of the following code snippet? Assume the input is: abcd

—

All snippets are wrong
Correct answer

What is the output of the following code snippet? Assume the input is: abcd

—

All snippets are wrong
Correct answer

What is the output of the following snippet of code?




Correct answer

What is the output of the following code?
15
10
20
5
Correct answer
15
is a non-empty list of distinct integers that has already been defined. Which of the following statements are true at the end of execution of the code given below?
is always equal to , i.e., == returns the value True
is a list of integers sorted in ascending order.
is a list of integers sorted in descending order.
Every element in is present in , but not necessarily in the same sequence.
Correct answers
is a list of integers sorted in ascending order.
is a list of integers sorted in descending order.
Every element in is present in , but not necessarily in the same sequence.
is a non-empty list of distinct integers that has already been defined. Which of the following statements are true at the end of execution of the code given below?
is always equal to , i.e., == returns the value True
is a list of integers sorted in ascending order.
is a list of integers sorted in descending order.
Every element in is present in , but not necessarily in the same sequence.
Correct answers
is a list of integers sorted in ascending order.
is a list of integers sorted in descending order.
Every element in is present in , but not necessarily in the same sequence.
What is the output of the following code?
15
10
20
5
Correct answer
15
What is the output of the following snippet of code?




Correct answer

Consider the following code snippet.
Which of the following statements is/are correct?
If the input is 45, then the output is
If the input is 80, then the output is
If the input is 5, then the output is
If the input is 25, then the output is
Correct answers
If the input is 80, then the output is
If the input is 5, then the output is
If the input is 25, then the output is
Consider the following code snippet.
Which of the following statements is/are correct?
If the input is 45, then the output is
If the input is 80, then the output is
If the input is 5, then the output is
If the input is 25, then the output is
Correct answers
If the input is 80, then the output is
If the input is 5, then the output is
If the input is 25, then the output is
What is the output of the following snippet of code?




Correct answer

is a list of tuples. Each tuple is of the form . Select all snippets of code that create a list containing the names of products with price greater than 500. You can assume that is already defined. Sample Input
Sample Output




Correct answers


Consider the following Python code:
Which of the following statements is/are true?
If x = 5 and y = 2, then output will be
If x = 4 and y = 8, then output will be
If x = 3 and y = 3, then output will be
If x = 10 and y = 5, then output will be
Correct answers
If x = 5 and y = 2, then output will be
If x = 4 and y = 8, then output will be
Consider the following Python code:
Which of the following statements is/are true?
If x = 5 and y = 2, then output will be
If x = 4 and y = 8, then output will be
If x = 3 and y = 3, then output will be
If x = 10 and y = 5, then output will be
Correct answers
If x = 5 and y = 2, then output will be
If x = 4 and y = 8, then output will be
is a list of tuples. Each tuple is of the form . Select all snippets of code that create a list containing the names of products with price greater than 500. You can assume that is already defined. Sample Input
Sample Output




Correct answers


Consider the following class:
Which of the following statements are TRUE?
contains 2 entries
returns 87
is equal to
is True
is a string
Correct answers
contains 2 entries
returns 87
is True
Inscript What is the output of the following snippet of code?
A written answer, not marked automatically.
Inscript What is the output of the following snippet of code?
A written answer, not marked automatically.
Consider the following class:
Which of the following statements are TRUE?
contains 2 entries
returns 87
is equal to
is True
is a string
Correct answers
contains 2 entries
returns 87
is True
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.
What is the output of the following snippet of code?
A written answer, not marked automatically.
What is the output of the following snippet of code?
A written answer, not marked automatically.
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 the output of the following snippet of code?
A written answer, not marked automatically.
What is the output of the following snippet of code?
A written answer, not marked automatically.
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.
Consider the following snippet of code. What will the output be?
A written answer, not marked automatically.
Consider the following snippet of code. What will the output be?
A written answer, not marked automatically.
What is printed?
A written answer, not marked automatically.
What is the output of the following snippet?
A written answer, not marked automatically.
Consider the following snippet of code and answer all the given subquestions:
What is the first line of the output?
10
14
6
18
Correct answer
14
Consider the following snippet of code and answer all the given subquestions:
What is the first line of the output?
10
14
6
18
Correct answer
14
What is the output of the following snippet?
A written answer, not marked automatically.
What is the output?
A written answer, not marked automatically.
Consider the following snippet of code and answer all the given subquestions:
What is the second line of the output?
6
162
36
48
Correct answer
162
Consider the following snippet of code and answer all the given subquestions:
What is the second line of the output?
6
162
36
48
Correct answer
162
What is the output?
A written answer, not marked automatically.
What is the output of the following code?
A written answer, not marked automatically.
What is the output of the following code?
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
What does the first statement output?
97
93
288
98
Correct answer
288
Based on the above program, answer the given subquestions.
What does the first statement output?
97
93
288
98
Correct answer
288
Based on the above program, answer the given subquestions.
What is printed in the second line?
P
C
B
None
Correct answer
B
Based on the above program, answer the given subquestions.
What is printed in the second line?
P
C
B
None
Correct answer
B
Based on the above program, answer the given subquestions.
What is the element at position [0][2] in ?
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
What is the element at position [0][2] in ?
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
What is the value of the second line of output?
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
What is the value of the second line of output?
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
A written answer, not marked automatically.
Consider the following snippet of code and answer all the given subquestions:
A written answer, not marked automatically.
Consider the following snippet of code and answer all the given subquestions:
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
A written answer, not marked automatically.
Based on the above program, answer the given subquestions.
A written answer, not marked automatically.