Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator +

Adds numbers or concatenates compatible sequences.

Version: Python 3.14; repository image, production runtime not attested

Syntax

left + right

Adds numbers or concatenates compatible sequences.

Use addition to combine numeric quantities or join sequences whose concrete types support concatenation. Mixed integer and floating-point arithmetic produces a floating-point result.

The forward and reflected special methods allow user-defined operands to supply their own result type. If both types decline the operation, Python raises a type error; adding a string directly to an integer is one example.

Joining strings requires string operands on both sides.

Syntax

left + right

__add__, __radd__ · TypeError

Worked example

2 + 0.5 → 2.5
"ab" + "c" → "abc"
"ab" + 3 → TypeError

Examples

print(-4 + 7)
print("ab" + "cd")

Result

3
abcd

Joining strings requires string operands on both sides.

Sources