Python Strings MCQs with Answers Set 02

Practice Python Strings MCQs with Answers Set 02 provided below. The MCQ Questions for [current-page:node:field_class] Strings [current-page:node:field_subject] with answers and follow the latest [current-page:node:field_board]/ NCERT and KVS patterns. Refer to more Chapter-wise MCQs for [current-page:node:field_board] [current-page:node:field_class] [current-page:node:field_subject] and also download more latest study material for all subjects

MCQ for [current-page:node:field_class] [current-page:node:field_subject] Strings

[current-page:node:field_class] [current-page:node:field_subject] students should review the 50 questions and answers to strengthen understanding of core concepts in Strings

Strings MCQ Questions [current-page:node:field_class] [current-page:node:field_subject] with Answers

Question. What is “Hello”.replace(“l”, “e”)?
(a) Heeeo
(b) Heelo
(c) Heleo
(d) None
Answer: a
Explanation: Execute in shell to verify.

Question. To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed)?
(a) s[]
(b) s.getitem(3)
(c) \(s.\_\_getitem\_\_(3)\)
(d) s.getItem(3)
Answer: c
Explanation: __getitem(..) can be used to get character at index specified as parameter.

Question. To return the length of string s what command do we execute?
(a) \(s.\_\_len\_\_()\)
(b) len(s)
(c) size(s)
(d) s.size()
Answer: a
Explanation: Execute in shell to verify.

Question. If a class defines the \( \_\_str\_\_(self) \) method, for an object obj for the class, you can use which command to invoke the \( \_\_str\_\_ \) method.
(a) \(obj.\_\_str\_\_()\)
(b) str(obj)
(c) print obj
(d) all of the mentioned
Answer: d
Explanation: Execute in shell to verify.

Question. To check whether string s1 contains another string s2, use ________
(a) \(s1.\_\_contains\_\_(s2)\)
(b) s2 in s1
(c) s1.contains(s2)
(d) si.in(s2)
Answer: a
Explanation: s2 in s1 works in the same way as calling the special function \( \_\_contains\_\_ \).

Question. Suppose i is 5 and j is 4, i + j is same as ________
(a) \(i.\_\_add(j)\)
(b) \(i.\_\_add\_\_(j)\)
(c) \(i.\_\_Add(j)\)
(d) \(i.\_\_ADD(j)\)
Answer: b
Explanation: Execute in shell to verify.

Question. What will be the output of the following Python code?
class Count:
    def __init__(self, count = 0):
        self.__count = count
c1 = Count(2)
c2 = Count(2)
print(id(c1) == id(c2), end = " ")
s1 = "Good"
s2 = "Good"
print(id(s1) == id(s2))
(a) True False
(b) True True
(c) False True
(d) False False
Answer: c
Explanation: Execute in the shell objects cannot have same id, however in the case of strings its different.

Question. What will be the output of the following Python code?
class Name:
    def __init__(self, firstName, mi, lastName):
        self.firstName = firstName
        self.mi = mi
        self.lastName = lastName
firstName = "John"
name = Name(firstName, 'F', "Smith")
firstName = "Peter"
name.lastName = "Pan"
print(name.firstName, name.lastName)
(a) Peter Pan
(b) John Pan
(c) Peter Smith
(d) John Smith
Answer: b
Explanation: Execute in the shell to verify.

Question. What function do you use to read a string?
(a) input(“Enter a string”)
(b) eval(input(“Enter a string”))
(c) enter(“Enter a string”)
(d) eval(enter(“Enter a string”))
Answer: a
Explanation: Execute in shell to verify.

Question. Suppose x is 345.3546, what is format(x, “10.3f”) (_ indicates space).
(a) __345.355
(b) ___345.355
(c) ____345.355
(d) _____345.354
Answer: b
Explanation: Execute in the shell to verify.

Question. What will be the output of the following Python code?
print("abc DEF".capitalize())
(a) abc def
(b) ABC DEF
(c) Abc def
(d) Abc Def
Answer: c
Explanation: The first letter of the string is converted to uppercase and the others are converted to lowercase.

Question. What will be the output of the following Python code?
print("abc. DEF".capitalize())
(a) abc. def
(b) ABC. DEF
(c) Abc. def
(d) Abc. Def
Answer: c
Explanation: The first letter of the string is converted to uppercase and the others are converted to lowercase.

Question. What will be the output of the following Python code?
print("abcdef".center())
(a) cd
(b) abcdef
(c) error
(d) none of the mentioned
Answer: c
Explanation: The function center() takes at least one parameter.

Question. What will be the output of the following Python code?
print("abcdef".center(0))
(a) cd
(b) abcdef
(c) error
(d) none of the mentioned
Answer: b
Explanation: The entire string is printed when the argument passed to center() is less than the length of the string.

Question. What will be the output of the following Python code?
print('*', "abcdef".center(7), '*')
(a) * abcdef *
(b) * abcdef *
(c) *abcdef *
(d) * abcdef*
Answer: b
Explanation: Padding is done towards the left-hand-side first when the final string is of odd length. Extra spaces are present since we haven’t overridden the value of sep.

Question. What will be the output of the following Python code?
print('*', "abcdef".center(7), '*', sep='')
(a) * abcdef *
(b) * abcdef *
(c) *abcdef *
(d) * abcdef*
Answer: d
Explanation: Padding is done towards the left-hand-side first when the final string is of odd length.

Question. What will be the output of the following Python code?
print('*', "abcde".center(6), '*', sep='')
(a) * abcde *
(b) * abcde *
(c) *abcde *
(d) * abcde*
Answer: c
Explanation: Padding is done towards the right-hand-side first when the final string is of even length.

Question. What will be the output of the following Python code?
print("abcdef".center(7, 1))
(a) 1abcdef
(b) abcdef1
(c) abcdef
(d) error
Answer: d
Explanation: TypeError, the fill character must be a character, not an int.

Question. What will be the output of the following Python code?
print("abcdef".center(7, '1'))
(a) 1abcdef
(b) abcdef1
(c) abcdef
(d) error
Answer: a
Explanation: The character ‘1’ is used for padding instead of a space.

Question. What will be the output of the following Python code?
print("abcdef".center(10, '12'))
(a) 12abcdef12
(b) abcdef1212
(c) 1212abcdef
(d) error
Answer: d
Explanation: The fill character must be exactly one character long.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy'))
(a) 2
(b) 0
(c) error
(d) none of the mentioned
Answer: a
Explanation: Counts the number of times the substring ‘yy’ is present in the given string.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 1))
(a) 2
(b) 0
(c) 1
(d) none of the mentioned
Answer: a
Explanation: Counts the number of times the substring ‘yy’ is present in the given string, starting from position 1.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 2))
(a) 2
(b) 0
(c) 1
(d) none of the mentioned
Answer: c
Explanation: Counts the number of times the substring ‘yy’ is present in the given string, starting from position 2.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('xyy', 0, 100))
(a) 2
(b) 0
(c) 1
(d) error
Answer: a
Explanation: An error will not occur if the end value is greater than the length of the string itself.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('xyy', 2, 11))
(a) 2
(b) 0
(c) 1
(d) error
Answer: b
Explanation: Counts the number of times the substring ‘xyy’ is present in the given string, starting from position 2 and ending at position 11.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('xyy', -10, -1))
(a) 2
(b) 0
(c) 1
(d) error
Answer: b
Explanation: Counts the number of times the substring ‘xyy’ is present in the given string, starting from position 2 and ending at position 11.

Question. What will be the output of the following Python code?
print('abc'.encode())
(a) abc
(b) ‘abc’
(c) b’abc’
(d) h’abc’
Answer: c
Explanation: A bytes object is returned by encode.

Question. What is the default value of encoding in encode()?
(a) ascii
(b) qwerty
(c) utf-8
(d) utf-16
Answer: c
Explanation: The default value of encoding is utf-8.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".endswith("xyy"))
(a) 1
(b) True
(c) 3
(d) 2
Answer: b
Explanation: The function returns True if the given string ends with the specified substring.

Question. What will be the output of the following Python code?
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
(a) 0
(b) 1
(c) True
(d) False
Answer: d
Explanation: The function returns False if the given string does not end with the specified substring.

MCQs for Strings [current-page:node:field_subject] [current-page:node:field_class]

Students can use these MCQs for Strings to quickly test their knowledge of the chapter. These multiple-choice questions have been designed as per the latest syllabus for [current-page:node:field_class] [current-page:node:field_subject] released by [current-page:node:field_board]. Our expert teachers suggest that you should practice daily and solving these objective questions of Strings to understand the important concepts and better marks in your school tests.

Strings NCERT Based Objective Questions

Our expert teachers have designed these [current-page:node:field_subject] MCQs based on the official NCERT book for [current-page:node:field_class]. We have identified all questions from the most important topics that are always asked in exams. After solving these, please compare your choices with our provided answers. For better understanding of Strings, you should also refer to our NCERT solutions for [current-page:node:field_class] [current-page:node:field_subject] created by our team.

Online Practice and Revision for Strings [current-page:node:field_subject]

To prepare for your exams you should also take the [current-page:node:field_class] [current-page:node:field_subject] MCQ Test for this chapter on our website. This will help you improve your speed and accuracy and its also free for you. Regular revision of these [current-page:node:field_subject] topics will make you an expert in all important chapters of your course.

FAQs

Where can I access latest Python Strings MCQs with Answers Set 02?

You can get most exhaustive Python Strings MCQs with Answers Set 02 for free on StudiesToday.com. These MCQs for are updated for the 2026-27 academic session as per examination standards.

Are Assertion-Reasoning and Case-Study MCQs included in the [current-page:node:field_subject] [current-page:node:field_class] material?

Yes, our Python Strings MCQs with Answers Set 02 include the latest type of questions, such as Assertion-Reasoning and Case-based MCQs. 50% of the paper is now competency-based.

How do practicing [current-page:node:field_subject] MCQs help in scoring full marks in [current-page:node:field_class] exams?

By solving our Python Strings MCQs with Answers Set 02, students can improve their accuracy and speed which is important as objective questions provide a chance to secure 100% marks in the .

Do you provide answers and explanations for Python Strings MCQs with Answers Set 02?

Yes, MCQs for have answer key and brief explanations to help students understand logic behind the correct option as its important for 2026 competency-focused exams.

Can I practice these [current-page:node:field_subject] [current-page:node:field_class] MCQs online?

Yes, you can also access online interactive tests for Python Strings MCQs with Answers Set 02 on StudiesToday.com as they provide instant answers and score to help you track your progress in .