Print in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Print in python

In print statement in python if there are two arguments for addition like 6 + 3 how is is the sum taken and displayed ?

25th Aug 2020, 2:05 AM
Sanjay Kamath
Sanjay Kamath - avatar
2 Answers
+ 3
The + operator calls the __add__ method. The __add__ method takes 2 arguments: object.__add__(self,other) or in this case: 6.__add__(3) which returns self - (-object) or 6 - (-3). Once it has been returned, theĀ print() functionĀ printsĀ the specified message to the screen, or other standard output device. The message can be a string, or any other object, the object will be converted into a string before written to the screen.
25th Aug 2020, 2:50 AM
Steven M
Steven M - avatar
+ 1
Steven M Thanks
17th Oct 2020, 12:11 AM
Sanjay Kamath
Sanjay Kamath - avatar