What will be the output of `print('5' + '5')`?

Master Python with the PCAP Certification! Explore interactive quizzes and detailed explanations to ensure your exam success. Gain confidence and get certified!

In Python, when you use the + operator with strings, it performs string concatenation. This means that it will combine the two strings into one single string rather than performing any arithmetic operation.

In the expression print('5' + '5'), both operands are strings: the first '5' and the second '5'. Instead of adding the numerical values, Python treats them as sequences of characters. Therefore, when they are concatenated, the result is a new string that combines these characters together.

So, '5' + '5' results in '55', which is why the output of that print statement is '55'. This illustrates the concept of string concatenation in Python, which is distinct from numeric addition.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy