Important Python Mcqs

To concatenate two strings to a third, what statements are applicable?

a) s3 = s1 . s2

b) s3 = s1.add(s2)

c) s3 = s1.__add__(s2)

d) s3 = s1 * s2

Answer:

c) s3 = s1.__add__(s2)

Explanation:

The __add__() method in Python specifies what happens when you call + on two objects. When you call obj1 + obj2, you are essentially calling obj1. __add__(obj2). So option c is correct.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?