In Python, the + operator adds numeric values, from whole numbers to decimals: 5 + 3 gives 8. It’s a simple tool you’ll use often in calculations. The same symbol can also join strings, so the values you combine matter—a small detail that keeps code clear and predictable.

Multiple Choice

What does the + operator do in a numeric expression?

In Python, the + operator is used to perform addition in numeric expressions. When applied to numeric values, it calculates the sum of its operands. For example, if you have two numbers, such as 5 and 3, using the + operator like this: `5 + 3`, the result will be 8. This operator is fundamental in programming for mathematical calculations, allowing for the straightforward addition of integers and floating-point numbers. The versatility of the + operator also extends beyond simple arithmetic; it can be used in string concatenation, where it combines strings together. However, in the context of numeric expressions, its primary function is to add values together, making it an essential operator in Python programming.

In Python, the + operator adds numeric values and returns their sum. Write 5 + 3, and Python evaluates the expression as 8. It’s a small symbol with a big job: addition shows up in everything from counting items to calculating prices, distances, and averages.

The operator is easy to recognize, but understanding how Python handles it helps make code clearer and more reliable. Let’s look at how + works with numbers, where it fits in a larger expression, and why the same symbol can behave differently with other kinds of data.

The basic job of +

An expression such as 5 + 3 has three parts: a value, an operator, and another value. The values on either side are called operands. Python applies the operator to them, then produces a result.


total = 5 + 3

print(total)

The output is:


8

Here, 5 and 3 are integers. Python adds them, then stores the result, 8, in the variable total. The name of the variable is up to the person writing the code; the calculation itself is handled by the + operator.

Addition also works with floating-point numbers, which represent values with a decimal part:


price = 4.50 + 2.25

print(price)

The result is 6.75. Integers and floating-point numbers are both numeric types, so they can be used in addition. When an integer and a float appear together, Python returns a float:


result = 6 + 1.5

print(result)

This prints 7.5. Python keeps the decimal form because one of the values was a float.

Adding values stored in variables

In real code, numbers often come from variables rather than appearing directly in a calculation. That makes expressions easier to reuse and update.


apples = 4

oranges = 7

fruit_count = apples + oranges

print(fruit_count)

The output is 11. Python looks up the current value of each variable, adds those values, and assigns the sum to fruit_count.

This pattern is useful whenever a program needs to combine quantities. A shop might add the cost of two items. A weather tool might add rainfall totals from two days. A game might increase a player’s score after collecting points. The details change, but the operation is the same: take two numeric values and find their sum.

You can also add a value to a variable by using augmented assignment:


score = 10

score += 3

print(score)

The output is 13. The += operator means “add this value to the current value, then assign the result back.” In this example, it has the same effect as:


score = score + 3

The shorter form is common when updating a total, counter, or score. It’s handy, but it’s still addition at work.

What happens in a longer expression?

Python can evaluate several operations in one expression. For example:


answer = 2 + 3 * 4

print(answer)

The result is 14, not 20, because multiplication is carried out before addition. Python follows operator precedence rules, much like the rules used in standard arithmetic.

Parentheses can make the intended order more obvious:


answer = (2 + 3) * 4

print(answer)

Now the result is 20. Python adds 2 and 3 first, then multiplies the sum by 4.

This matters even in short pieces of code. A pair of parentheses can save someone reading the program from having to pause and work out which operation happens first. If an expression feels hard to scan, adding parentheses may make it clearer—even when Python doesn’t require them.

Addition isn’t the same as string joining

The + symbol also works with strings, but it does something different there: it joins the text together. This is called concatenation.


first = "Good"

second = " morning"

message = first + second

print(message)

The output is:


Good morning

With numeric values, + adds. With strings, it joins. The data type determines what the operator does.

Mixing a number and a string directly usually raises a TypeError:


age = 12

message = "Age: " + age

Python can’t add the text "Age: " to the integer 12 as though they were the same kind of thing. To include the number in a message, convert it to a string:


age = 12

message = "Age: " + str(age)

print(message)

Or use an f-string, which is often easier to read:


age = 12

message = f"Age: {age}"

print(message)

Knowing this distinction prevents a common source of confusion. The symbol looks the same, yet its effect depends on the values around it.

A few useful details about numeric addition

Python’s + operator can add more than two values when the expression is written out:


total = 2 + 4 + 6

print(total)

The result is 12. For a series of numbers stored in a list, Python provides the built-in sum() function:


temperatures = [18, 20, 17]

daily_total = sum(temperatures)

print(daily_total)

This also produces 55. The + operator is still the basic tool behind addition, while sum() offers a neat way to total a collection of values.

One small wrinkle: decimal calculations can sometimes show tiny rounding differences. For instance, a result may display as 0.30000000000000004 instead of exactly 0.3. That happens because many decimal fractions can’t be represented perfectly in binary floating-point storage. For ordinary calculations, this is often harmless. For money, programs commonly use Python’s decimal module when exact decimal behavior matters.

The key idea

When Python sees + between numeric values, it adds them and returns their sum. That works with integers and floats, and it also works when the numbers are held in variables. In longer expressions, precedence rules determine the order of operations; parentheses can make that order easier to see.

Just remember that + is not limited to arithmetic. It can join strings, too, and Python responds according to the types it receives. Once that distinction is clear, the operator feels less like a symbol to memorize and more like a reliable tool—one that helps a program keep totals, update values, and make simple calculations readable.