CBSE · 083Class XII · 2023Section A1 mark

Question 05

30 March 2023 · Computer Science (083)

Select the correct output of the code :

python
S = "Amrit Mahotsav @ 75"
A = S.partition(" ")
print(A)

Answer

(d) ('Amrit','', 'Mahotsav @ 75')

Explanation

str.partition(sep) returns a 3-tuple: (part_before_sep, sep, part_after_sep). Splitting on the first space gives ('Amrit', ' ', 'Mahotsav @ 75'). Note: the original paper printed lowercase 'a' which is an error; CBSE accepted (d) when reading 'A'.