Quiz Space

Programming in Python Quiz 1: 13 July 2025 (May 2025 term)

Question 1

+3 marksOne correct option

Consider the following code:
text = " >>> Hello, Python! <<< "
to_strip = " <>"
A = text.strip(to_strip)
B = text.lstrip(to_strip)
C = text.rstrip(to_strip)
D = text.strip()
print(A)
print(B)
print(C)
print(D)
Which of the following is the correct output?

  1. A

    Hello, Python!
    " Hello, Python! <<< "
    " >>> Hello, Python! "
    >>> Hello, Python! <<<

  2. B

    Hello, Python!
    Hello, Python! <<<
    >>> Hello, Python!
    >>> Hello, Python! <<<

  3. C

    Hello, Python!.
    >>> Hello, Python!
    Hello, Python! <<<
    >>> Hello, Python! <<<

  4. D

    >>> Hello, Python! <<<
    Hello, Python! <<<
    >>> Hello, Python!
    Hello, Python!

Question 2

+3 marksOne correct option

Consider a Python program that takes a sentence (which may contain both uppercase and lowercase letters, spaces, and punctuation) and prints the number of vowels present.
Snippet-1
sentence = input()
count = 0
vowels = set("aeiouAEIOU")
for char in sentence:
if char in vowels:
count += 1
print(count)
Snippet-2
sentence = input()
count = 0
for char in sentence.lower():
if char in ['a', 'e', 'i', 'o', 'u']:
count += 1
print(count)
Which of these two snippets is correct?

  1. A

    Only snippet-1 is correct

  2. B

    Only snippet-2 is correct

  3. C

    Both snippets are correct

  4. D

    Both snippets are wrong

Question 3

+3 marksOne correct option

What is the output of the following Python code?
data = ["alpha", "beta", "gamma"]
data[1] = data[1].replace("e", data[0][1])
data[2] = data[2][::-1].replace("a", data[0][3])
print(data)

  1. A

    ['alpha', 'blta', 'hmmhg']

  2. B

    ['alpha', 'blta', 'ghmmh']

  3. C

    ['alpha', 'blta', 'htlb']

  4. D

    ['alpha', 'blta', 'hmmh']

11 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the Python Quiz 1 13 Jul 2025 paper

The IIT Madras BS Programming in Python (Python) Quiz 1 paper sat on 13 Jul 2025, in the May 2025 term: 14 questions for 50 marks in 120 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeaturePython Quiz 1 13 Jul 2025 at a glance
TermMay 2025 term
SubjectProgramming in Python
Course codeBSCS1002
Questions14
Marks50
Duration120 min
MCQ7
MSQ3
Numerical4
Official paperIIT M DIPLOMA AN EXAM QDD2 13 July 2025
Negative markingNo negative marking.
Updated

Same Quiz 1, other subjects

More Python