adplus-dvertising

Welcome to the Strings in Python MCQs Page

Dive deep into the fascinating world of Strings in Python with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Strings in Python, a crucial aspect of Python. In this section, you will encounter a diverse range of MCQs that cover various aspects of Strings in Python, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Python.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Strings in Python. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Python.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Strings in Python. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Strings in Python MCQs | Page 2 of 13

Q11.
What is the output of the following code ?
class father:
    def __init__(self, param):
        self.o1 = param
 
class child(father):
    def __init__(self, param):
        self.o2 = param
 
>>>obj = child(22)
>>>print "%d %d" % (obj.o1, obj.o2)
Discuss
Answer: (d).Error is generated
Q12.
What is the output of the following code ?
class tester:
    def __init__(self, id):
        self.id = str(id)
        id="224"
 
>>>temp = tester(12)
>>>print(temp.id)
Discuss
Answer: (c).12
Q13.
What is the output of the following code ?
>>>example = "snow world"
>>>print("%s" % example[4:7])
Discuss
Answer: (a).wo
Q14.
What is the output of the following code ?
>>>example = "snow world"
>>>example[3] = 's'
>>>print example
Discuss
Answer: (c).Error
Q15.
What is the output of the following code ?
>>>max("what are you")
Discuss
Answer: (d).y
Q16.
Given a string example=”hello” what is the output of example.count(l)
Discuss
Answer: (a).2
Q17.
What is the output of the following code ?
>>>example = "helle"
>>>example.find("e")
Discuss
Answer: (c).1
Q18.
What is the output of the following code ?
>>>example = "helle"
>>>example.rfind("e")

a.

-1

b.

4

c.

3

d.

1

Discuss
Answer: (b).4
Q19.
What is the output of the following code ?
>>>example="helloworld"
>>>example[::-1].startswith("d")
Discuss
Answer: (b).True
Q20.
To concatenate two strings to a third what statements are applicable ?
Discuss
Answer: (c).s3 = s1.__add__(s2)
Page 2 of 13

Suggested Topics

Are you eager to expand your knowledge beyond Python? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!