Test Index

Python Revision Tour Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 81 of 102
Marks: +1, -0
Select the correct output of the code :
S= "Amrit Mahotsav @ 75"
A=S.partition (" ")
print (A)
[CBSE 2023 Set 4]
Solution:  
Concept:
str.partition(sep) splits the string at the first occurrence of sep and always returns a tuple of three parts: (part before, the separator itself, part after).
Explanation:
The first space in "Amrit Mahotsav @ 75" is after Amrit.
Part before = 'Amrit', separator = ' ', part after = 'Mahotsav @ 75'
('Amrit', ' ', 'Mahotsav @ 75')
Option (b) is a list (that is what split() gives), and (c) leaves out the separator.
Answer:
Option D (('Amrit', ' ', 'Mahotsav @ 75'))
© examsnet.com
Advertisements
Go to Question: