Question 41 markMCQSection A

What is the output of the following code snippet ?

``python

s='War and Peace by Leo Tolstoy'

print(s.partition("by"))

``

Review of Python Basics (Class XI Recap)
String Methods — partition()

Options

(A)('War and Peace ', 'by', ' Leo Tolstoy')
(B)['War and Peace ', 'by', ' Leo Tolstoy']
(C)('War and Peace ', ' Leo Tolstoy')
(D)['War and Peace ', ' Leo Tolstoy']

Official answer

Option A — ('War and Peace ', 'by', ' Leo Tolstoy') is correct, because str.partition(sep) always returns a 3-element tuple: (text before separator, the separator itself, text after separator).

Answer keywords:partition()string methodstuple return typesplit vs partitionPython strings

Marking scheme

  1. 1.1 mark: for correctly selecting option A.

Hint

partition() always returns a 3-element TUPLE: (before, separator, after).

Quick oral answer

partition() splits at the first occurrence of the separator and returns a 3-element tuple (before, separator, after), so the answer here is the tuple with 'War and Peace ', 'by', and ' Leo Tolstoy'.

Common mistakes

  1. 1.Confusing partition()'s tuple output with split()'s list output.
  2. 2.Forgetting that the separator itself is included as the middle element of the returned tuple.

Analysis and explanation

partition() is a string method with a fixed, predictable 3-part return structure that is frequently tested in CBSE MCQs.


Concept

  • s.partition(sep) splits the string at the FIRST occurrence of sep and returns exactly 3 items as a tuple (never a list): (before, sep, after).
  • For s = 'War and Peace by Leo Tolstoy' and sep = "by": before = 'War and Peace ', separator = 'by', after = ' Leo Tolstoy'.

Why other options are wrong

  • Option B — uses square brackets [...], implying a list; partition() always returns a tuple, not a list.
  • Option C — has only 2 elements and omits the separator itself; partition() always includes the separator as the middle element even when found.
  • Option D — uses square brackets (list) AND omits the separator — combines both errors above.

Exam trap

  • Students often confuse partition() (always 3-tuple, separator included) with split() (returns a list, separator excluded).

Interesting facts

If the separator is not found in the string, partition() returns (original_string, '', '') — the original string followed by two empty strings.

There is also an rpartition() method that splits at the LAST occurrence of the separator instead of the first.

Question details

Q4 of 48 questions

Board
CBSE
Class
Class 12
Subject
Computer Science
Year
2026
Section
Section A
Marks
1
Type
MCQ
Chapter
Review of Python Basics (Class XI Recap)
Topic
String Methods — partition()
Bloom's level
apply
Syllabus topic
Unit 1: Computational Thinking and Programming – 2 — String Manipulation: partition() method
Author
CBSE
Reviewed by
Padhantu Academic Team

Spotted a mistake or something unclear?

Tell us and we will fix it.

Frequently asked questions

What does partition() return if the separator is not found?

It returns a tuple of (original_string, '', '') — the whole string as the first element and two empty strings for the separator and the remainder.

What is the difference between partition() and split()?

partition() splits only at the first occurrence and returns a 3-element tuple including the separator; split() can split at every occurrence (or a limited count) and returns a list without the separator.