Question 1
Consider the following code snippet:
What does the code snippet print?
True -4 True 1
False -2 False 0
True -2 False 0
True 0 True 0

The IIT Madras BS Programming in Python (Python) End Term paper sat on 13 Sept 2026, in the May 2026 term, set S2: 17 questions for 48 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 code snippet:
What does the code snippet print?
True -4 True 1
False -2 False 0
True -2 False 0
True 0 True 0
Correct answer
True -2 False 0
Consider the following code snippet.
What is the output?
4
10
16
100
Correct answer
10
It moves all multiples of 3 to the left and all other elements to the right (a partition), without changing the relative order of the non-multiples themselves.
Correct answer
Consider the following code snippet.
What will be the output?
Correct answer
What is the output of the above code?
Correct answer
Consider the following class used at the school fruit stall to track volunteer hours.
True, 1.25
True, 7.00
False, 7.00
False, 1.25
Correct answer
True, 7.00
Correct answers
Consider the following code snippet.
Select all correct statements.
Correct answers
Consider the following snippet.
Select all that apply.
Correct answers
Consider the following code snippet.
What is the output of the above code?
Correct answer: 5
At Hari's yoga class, a running total is maintained while processing attendance codes.
What is the output of the above code?
Correct answer: 21
Consider the following code snippet.
Correct answer: 7
Consider the following code snippet.
Enter the sum of all the values present in the dictionary.
Correct answer: 10
In Madhava's shop, each item is stored in its own tray. Each tray can have a maximum of 40 items. Madhava stores the inventory as a dictionary, where the key is the item name and the value is a list containing the quantity of that item in each tray.
When Madhava counts the inventory, an item contributes to the total only if its overall quantity is at least 80. Otherwise, the item is added to a reload list.
Consider the following code.
What is the output of the above code?
Correct answer: 181
Based on the above data, answer the given subquestions
What does the given code print?
Ahmed 2755
Vishaka 2755
Harry 2353
Correct answer
Vishaka 2755
Consider the following code snippet:
Based on the above data, answer the given subquestions
Correct answer: 2
Consider the following code snippet:
Based on the above data, answer the given subquestions
What is the value of the second line of output?
Correct answer: 90