How to Add Numbers in Python

To add numbers in Python, you can use the + operator or the += operator.

The following examples show how to add numbers in Python using different methods.

Using + Operator

We can use the + operator to add numbers in Python.

Suppose we have the following numbers:

# Declare numbers
a = 5
b = 6

# Add numbers
result = a + b

print("Result of addition:", result)

Output: 👇️

Result of addition: 11

In this example, we use the + operator to add the numbers a and b.

Using += Operator

We can use the += operator to add numbers in Python.

Suppose we have the following number:

# Declare number
a = 5

# Add number
a += 11

print("Result of addition:", a)

Output: 👇️

Result of addition: 16

In this example, we use the += operator to add 11 to the number a.