uiz Space

September 2025 term · Programming in Python · BSCS1002

Programming in Python Quiz 1: 26 October 2025, Set 1 (September 2025 term)

The IIT Madras BS Programming in Python (Python) Quiz 1 paper sat on 26 Oct 2025, in the September 2025 term, set 1: 18 questions for 54 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
18
Marks
54
Duration
120 min
MCQ
10
MSQ
2
Written
6

Updated

Official paper: IIT M IMPROVEMENT AN EXAM QIA4 26 Oct · No negative marking.

Question 1

+1 markOne correct option

THIS IS QUESTION PAPER FOR THE SUBJECT "FOUNDATION LEVEL : INTRODUCTION TO PYTHON (COMPUTER BASED EXAM)" ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT? CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN. (IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)

  1. A

    YES

  2. B

    NO

Show answer

Correct answer

  • A

    YES

Question 2

+1 markOne correct option

Useful InformationNAT → integerFor all NAT questions in this exam, the answer will always be an integer and not a float value. If the answer to a question is 18, then just enter that value. Do not enter 18.0

  1. A

    Instructions has been mentioned above.

  2. B

    This Instructions is just for a reference & not for an evaluation.

Show answer

Correct answer

  • A

    Instructions has been mentioned above.

Question 3

+3 marksOne correct option

Consider the following Python code. What will be the output?s = "programming" print(s[::-1].replace("g", "#"))

  1. A

    #nimmarrop#

  2. B

    #nimmar#orp

  3. C

    programmin#

  4. D

    gni#marropg

Show answer

Correct answer

  • B

    #nimmar#orp

Question 4

+3 marksOne correct option

Consider the following Python code. What will be the output?x, y, z = "", "python", 0 print((x or y) and (z or len(y)))

  1. A

    6

  2. B

    ""

  3. C

    "python"

  4. D

    0

  5. E

    True

Show answer

Correct answer

  • A

    6

Question 5

+3 marksOne correct option

Consider the following python code. What will the value stored in x at the end of the program execution?x = 5 x = x + 2.0 x = str(x) + "3" x = x * 2 x = [x] x = x + [10]

  1. A

    ['7.03', '7.03', 10]

  2. B

    ['7.03', 10]

  3. C

    ['7.037.03']

  4. D

    ['7.037.03', 10]

Show answer

Correct answer

  • D

    ['7.037.03', 10]

Question 6

+4 marksOne correct option

You have a list of lists:You want to compute the sum of all even numbers greater than 3. Consider the two code snippets below (with the condition left blank):Snippet-1s = 0 for row in data: for val in row: __________: s += val print(s) Snippet-2s = 0 i = 0 while i 3: s += data[i][j] j += 1 i += 1 print(s) Which of the following conditions, when filled in the blanks in both snippets, will give the correct result?

  1. A

    Snippet 1: if element % 2 == 0 and element > 3: Snippet 2: i > len(data[j]

  2. B

    Snippet 1: if element % 2 != 0 and element > 3: Snippet 2: i < len(data[j]

  3. C

    Snippet 1: if element % 2 == 0 and element > 3: Snippet 2: j < len(data[i]):

  4. D

    Snippet 1: if element % 2 == 0 and element Snippet 2: j > len(data[i]):

Show answer

Correct answer

  • C

    Snippet 1: if element % 2 == 0 and element > 3: Snippet 2: j < len(data[i]):

Question 7

+4 marksOne correct option

Assume s is a str variable. What is the type of the expression "".join(sorted(set(s.lower()))) ?

  1. A

    int

  2. B

    set

  3. C

    list

  4. D

    bool

  5. E

    str

  6. F

    NoneType

  7. G

    The code raises an error.

Show answer

Correct answer

  • E

    str

Question 8

+4 marksOne or more correct options

Consider the following Python code:t = (5, [10, 20], (30, [40, 50],(30,))) Which of the following statements are valid? (Select all that apply)

Select all that apply.

  1. A

    t[1].append(25)

  2. B

    t[2] += (60,)

  3. C

    t[2][0] = 35

  4. D

    t[2][2].append(60)

  5. E

    t[2][1][0] = 45

Show answer

Correct answers

  • A

    t[1].append(25)

  • E

    t[2][1][0] = 45

Question 9

+3 marksOne or more correct options

Consider the below code.if x: print('x') else: if y: if z: print('z') print('y') else: print('none') Select the possible output(s) of the given code, assuming any possible values for x , y , and z .

Select all that apply.

  1. A

    x

  2. B

    z y

  3. C

    x y

  4. D

    none

  5. E

    x z

  6. F

    y

Show answer

Correct answers

  • A

    x

  • B

    z y

  • D

    none

  • F

    y

Question 10

+4 marksWritten answer

Consider the following Python code:for i in range(1, 6): for j in range(1, 6): for k in range(1, 2): if i == j: print("-") else: print("*", end=" ") print("+") How many lines will be printed when this code is executed?

Show answer

A written answer, not marked automatically.

Question 11

+3 marksWritten answer

Consider the following Python code:for i in range(1, 5): for j in range(1, 5): if j == 3: break if i == 2: continue print(i, j) How many lines will be printed when this code is executed?

Show answer

A written answer, not marked automatically.

Question 12

+3 marksWritten answer

Consider the following Python code:P = {1, 2, 3, 4} Q = {3, 4, 5, 6} R = {4, 5, 6, 7} S = {2, 4, 6, 8} result = ((P | Q) - R) & S print(result) How many elements will be present in result?

Show answer

A written answer, not marked automatically.

Question 13

+4 marksOne correct option

Consider the following snippet of code and answer the given sub-questions:def analyze(data): result = [] for item in data: if isinstance(item, tuple): total = 0 for x in item: if x % 2

0: total += x result.append(total) elif isinstance(item, int) and item % 2

1: result.append(item * 3) else: continue return result sample = [(2, 5, 6), 7, (1, 3), 4, (8, 2, 1)] output = analyze(sample)

What is the value of output after executing the given code?

  1. A

    [8, 21, 0, 4, 10]

  2. B

    [8, 21, 4, 2, 10]

  3. C

    [8, 21, 0, 10]

  4. D

    [8, 7, 0, 10]

Show answer

Correct answer

  • C

    [8, 21, 0, 10]

Question 14

+4 marksWritten answer

Consider the following snippet of code and answer the given sub-questions:def analyze(data): result = [] for item in data: if isinstance(item, tuple): total = 0 for x in item: if x % 2

0: total += x result.append(total) elif isinstance(item, int) and item % 2

1: result.append(item * 3) else: continue return result sample = [(2, 5, 6), 7, (1, 3), 4, (8, 2, 1)] output = analyze(sample)

How many times is the inner for x in item: loop executed in total when running analyze(sample) ?

Show answer

A written answer, not marked automatically.

Question 15

+4 marksOne correct option

Consider the following code:def flipper(matrix): transformed = [] for row in matrix: new_row = [] for element in row: if element 5 ] return transformed, result matrix = [[1, -2, 3], [4, 5, -6], [7, 8]] out1, out2 = flipper(matrix) print(out1) print(out2) Answer the subquestions based on the given data.

What is the value of out1 after executing the code?

  1. A

    [[1, -4, 9], [8, 15, -12], [21, 16]]

  2. B

    [[3, 0, 9], [8, 15, 0], [21, 16]]

  3. C

    [[3, 0, 9], [4, 15, 0], [21, 16]]

  4. D

    [[1, 0, 3], [8, 15, 0], [21, 16]]

Show answer

Correct answer

  • B

    [[3, 0, 9], [8, 15, 0], [21, 16]]

Question 16

+4 marksOne correct option

Consider the following code:def flipper(matrix): transformed = [] for row in matrix: new_row = [] for element in row: if element 5 ] return transformed, result matrix = [[1, -2, 3], [4, 5, -6], [7, 8]] out1, out2 = flipper(matrix) print(out1) print(out2) Answer the subquestions based on the given data.

What is the value of out2 after executing the code?

  1. A

    [3, 9, 8, 15, 21, 16]

  2. B

    [9, 8, 15, 21, 16]

  3. C

    [8, 15, 21, 16]

  4. D

    [3, 0, 9, 8, 15, 0, 21, 16]

Show answer

Correct answer

  • B

    [9, 8, 15, 21, 16]

Question 17

+1 markWritten answer

Consider the following snippet of code and answer the given sub-questions:def analyze(data): result = [] for item in data: if isinstance(item, tuple): total = 0 for x in item: if x % 2

0: total += x result.append(total) elif isinstance(item, int) and item % 2

1: result.append(item * 3) else: continue return result sample = [(2, 5, 6), 7, (1, 3), 4, (8, 2, 1)] output = analyze(sample)

Show answer

A written answer, not marked automatically.

Question 18

+1 markWritten answer

Consider the following code:def flipper(matrix): transformed = [] for row in matrix: new_row = [] for element in row: if element 5 ] return transformed, result matrix = [[1, -2, 3], [4, 5, -6], [7, 8]] out1, out2 = flipper(matrix) print(out1) print(out2) Answer the subquestions based on the given data.

Show answer

A written answer, not marked automatically.