MCQ Answer

<p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">print('abcd'.partition('cd'))</span></pre>

What will be the output of the following Python code?

print('abcd'.partition('cd'))


निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

print('abcd'.partition('cd'))
Topic : Sequence data types in python

A. (‘ab’, ‘cd’, ”)

B. (‘ab’, ‘cd’)

C. error एरर

D. none of the mentioned उल्लेखित कोई नहीं




Correct Answer is :

A. (‘ab’, ‘cd’, ”)



Explanation
The partition() method in Python splits a string into three parts based on a specified separator. It returns a tuple containing three elements:

The part of the string before the first occurrence of the separator.
The separator itself.
The part of the string after the separator.

Explanation:

The first element of the tuple is 'ab', which is the part of the string before the first occurrence of 'cd'.
The second element is 'cd', which is the separator itself.
The third element is an empty string '', which is the part of the string after the separator.
So, when you print the result, you'll see ('ab', 'cd', '').
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz