Python String MCQs: 12 Solved Questions on Slicing, Search and Methods

Solve 12 published Python string questions step by step. Trace indices, slices, return types and method contracts before checking each answer.

KnowledgeGate Team

Exam prep & CS education

2 Sep 20267 min read

Python string questions look short, but one character position, an omitted slice bound or a method contract can change the output. Before choosing an option, copy the string, mark positive and negative indices, trace one method at a time, and predict the exact value and type. The same discipline applies across split(), join(), search, case conversion, partition() and slicing. Coding & DSA Courses for Placements connects these Python habits to broader programming and problem-solving practice.

Python string rules to fix before the MCQs

Keep this rule sheet beside you while solving:

Operation

Rule

S[i]

Returns one character.

S[start:stop:step]

Excludes stop; an omitted bound follows the direction of step.

S.find(x)

Returns the first index, or -1 when x is absent.

S.index(x)

Returns the first index, but raises ValueError when x is absent.

S.partition(sep)

Always returns a tuple of three strings.

S.split(sep, maxsplit)

Returns a list with at most maxsplit + 1 pieces.

Strings are immutable, so a method creates a result rather than changing an existing string in place.

For S = "GATE Python", the positive indices are G=0, A=1, T=2, E=3, space=4, P=5, y=6, t=7, h=8, o=9, n=10. From the right, n=-1, o=-2, h=-3, t=-4, y=-5, P=-6. Therefore, S[5:] and S[-6:] both produce "Python"; S[::-1] produces "nohtyP ETAG"; S.find("t") is 7; and S.partition(" ") is ("GATE", " ", "Python").

Always name the output type too. partition() gives a tuple, while split() gives a list. Revisit Coding & CS Fundamentals when the underlying sequence rules need more work.

Python string MCQs 1 and 2: split(), join() and maxsplit

Question 1

Kendriya Vidyalaya Sangathan 2023

Identify the output of the following Python program segment:

 S='Python Programming'
 L=S.split()
 S=','.join(L)
 print(S)
A. Python Programming / Python Programming
B. Python,Programming / Python,Programming 
C. Python Programming, / Python Programming
D. Python, Programming, / Python, Programming

Answer: B. Python,Programming / Python,Programming .

S.split() first creates ['Python', 'Programming']. Joining that list with the exact separator ',' produces Python,Programming, with no space and no leading or trailing comma. The displayed option repeats the text around a slash, but Python itself prints only the value shown above. View solved question 1.

Question 2

Eklavya Model Residential Schools 2026

What will be the output of the following Python code snippet?

STR = "It is still a test"
print(STR.split('t', 3))
A. ['I', ' is s', 'ill a test']
B. ['I', ' is s', 'ill a ', 'es']
C. ['I', ' is s', 'ill a ', 'est']
D. ['I', ' is s', 'ill a ', 'es', '']

Answer: C. ['I', ' is s', 'ill a ', 'est'].

Trace the three allowed splits from left to right. They create the intermediate pieces 'I', ' is s' and 'ill a ', followed by the unsplit remainder 'est'. A maxsplit of 3 permits at most four list items, so the final list is ['I', ' is s', 'ill a ', 'est']. View solved question 2.

Python string MCQs 3 and 4: first occurrence with index() and find()

Question 3

Kendriya Vidyalaya Sangathan 2023

Identify the correct output of the following Python Code:

Str = 'Hello World!  Hello India!'
Pos = Str.index ('Hello')
print (Pos)
A.  0 / 0 
B. 13 / 13 
C. [0, 13] / [0, 13] 
D. (0, 13) / (0, 13)

Answer: A. 0 / 0.

The opening index ruler is H=0, e=1, l=2, l=3, o=4. Since the first Hello begins at index 0, Str.index('Hello') stops there and returns the integer 0. It does not collect all matches, so the later occurrence and the list or tuple distractors do not matter. View solved question 3.

Question 4

Kendriya Vidyalaya Sangathan 2023

If Str is a Python string as
 Str ='Hello World!'
  What will be the output of the following Python Command?
 print(Str.find('l'))
A.  2 / 2 
B. 3 / 3
C. [2, 3, 7] / [2, 3, 7] 
D. (2, 3, 7) / (2, 3, 7)

Answer: A. 2 / 2.

The relevant ruler is H=0, e=1, l=2, l=3. find('l') returns only the first matching position, which is 2. If the search were find('z'), the result would be -1; index('z') would instead raise ValueError. View solved question 4.

Python string MCQs 5 and 6: case conversion and valid methods

Question 5

Kendriya Vidyalaya Sangathan 2023

If S='python language' is a Python string, which of the following command will display the following output with 'P' in upper case and remaining in lower case ?
A. print(S.upper()) / print(S.upper()) 
B. print(S.title()) / print(S.title()) 
C. print(S.capitalize()) / print(S.capitalize())
D. print(S.sentence()) / print(S.sentence())

Answer: C. print(S.capitalize()) / print(S.capitalize()).

Compute each decisive result: S.upper() gives PYTHON LANGUAGE, S.title() gives Python Language, and S.capitalize() gives Python language. Only the last value has an uppercase P with every remaining letter lowercase. Python does not define sentence() as a string method. View solved question 5.

Question 6

Kendriya Vidyalaya Sangathan 2023

Which of the following functions cannot be used with string(str) data type?
A. islower() / islower()
B.  isupper() / isupper() 
C. isalpha() / isalpha()
D. isnum() / isnum()

Answer: D. isnum() / isnum().

The valid calls give exact Boolean values: 'gate'.islower() is True, 'GATE'.isupper() is True, and 'Gate'.isalpha() is True. Python has isnumeric() and isdigit(), but no str.isnum() method. Calling '123'.isnum() therefore raises AttributeError. View solved question 6.

Python string MCQs 7 and 8: the partition() contract

Question 7

Eklavya Model Residential Schools 2023

Which string method, out of the following, will always break the string into 3 parts in Python?
A. break
B. partition
C. mid
D. split

Answer: B. partition.

'key=value=7'.partition('=') uses only the first separator and returns ('key', '=', 'value=7'). Even when the separator is absent, 'key'.partition('=') returns three strings: ('key', '', ''). split() can produce a variable number of pieces, while break and mid are not Python string methods. View solved question 7.

Question 8

Eklavya Model Residential Schools 2026

What is the return type and structure of the Python string function partition()?
A. A Python list containing exactly 3 strings.
B. A Python tuple containing exactly 3 strings.
C. A Python list containing at least 3 strings.
D. A Python tuple containing at least 3 strings.

Answer: B. A Python tuple containing exactly 3 strings.

The result ('key', '=', 'value=7') establishes both properties: it is a tuple, and its length is exactly three. By contrast, 'a=b=c'.split('=') returns the list ['a', 'b', 'c'], whose length can change with the input. View solved question 8.

Python string MCQs 9 and 10: negative indexing and reverse slicing

Question 9

DSSSB 2021

What is output of the code in Python Language:
 >>> str1 = 'All the Best'
 >>> str1[-3]
A. 'l'
B. 'e'
C. 'h'
D. 'B'

Answer: B. 'e'.

Build the ruler from the right: B=-4, e=-3, s=-2, t=-1. The index -3 therefore selects the single character 'e', not a substring. View solved question 9.

Question 10

Kendriya Vidyalaya Sangathan 2026

Which of the following slicing examples will display content of string TXT in reversed order in Python?
A. print(TXT[::-1])
B. print(TXT[-1])
C. print(TXT[1-1])
D. print(TXT[0:-1])

Answer: A. print(TXT[::-1]).

With TXT = 'GATE', the slice TXT[::-1] starts from the end and steps left by -1, producing ETAG. The other values are TXT[-1] == 'E', TXT[1-1] == 'G', and TXT[0:-1] == 'GAT'. Those expressions select or omit characters, but none reverses the full string. View solved question 10.

Python string MCQs 11 and 12: bounded slices and collection types

Question 11

Kendriya Vidyalaya Sangathan 2026

Which of the following print statements will display output as RAMA in Python?
A. print("AMARDEEP"[3::-1])
B. print("AMARDEEP"[4::-1])
C. print("AMARDEEP"[2::-1])
D. print("AMARDEEP"[3:-1])

Answer: A. print("AMARDEEP"[3::-1]).

Mark A=0, M=1, A=2, R=3, D=4, E=5, E=6, P=7. The slice [3::-1] visits indices 3, 2, 1, 0, so it produces RAMA. The other results are DRAMA for [4::-1], AMA for [2::-1], and RDEE for [3:-1]. View solved question 11.

Question 12

Kendriya Vidyalaya Sangathan 2026

Which of the following is not an example of a collection in Python?
A. list 
B. bool
C. tuple 
D. str

Answer: B. bool.

A list, tuple and string are ordered collections of items or characters. The checks len([4, 5]) == 2, len((4, 5)) == 2, and len('KG') == 2 all work. A Boolean is the scalar value True or False, so len(True) raises TypeError. View solved question 12.

Review the Python string MCQs and choose the next practice step

Use your misses to choose the repair:

Missed questions

What to practise

Q1 to Q2

Trace each intermediate list before joining or limiting splits.

Q3 to Q4

Mark zero-based indices and separate find() from index() when text is absent.

Q5 to Q8

Revise exact method names, return types and fixed contracts.

Q9 to Q11

Draw positive and negative indices before evaluating a slice.

For Q12, separate sequence collections from scalar values. Retry only the questions you missed, hide the options, and write the exact value and type first.

Next, use Data Structures MCQs to practise state tracing across lists, stacks, queues, trees and graphs. Choose Python Course: Concepts, MCQs & Coding for structured Python study, or DSA Using Python to apply Python to data structures.