Foundations Updated 2026-09 View as Markdown

Basic Operators

This section explains how to use basic operators in Python.

This section explains how to use basic operators in Python.

Arithmetic Operators#

Just as any other programming languages, the addition, subtraction, multiplication, and division operators can be used with numbers.

python
number = 1 + 2 * 3 / 4.0
print(number)

Try to predict what the answer will be. Does python follow order of operations?

Another operator available is the modulo (%) operator, which returns the integer remainder of the division. dividend % divisor = remainder.

python
remainder = 11 % 3
print(remainder)

Using two multiplication symbols makes a power relationship.

python
squared = 7 ** 2
cubed = 2 ** 3
print(squared)
print(cubed)

Using Operators with Strings#

Python supports concatenating strings using the addition operator:

python
helloworld = "hello" + " " + "world"
print(helloworld)

Python also supports multiplying strings to form a string with a repeating sequence:

python
lotsofhellos = "hello" * 10
print(lotsofhellos)

Using Operators with Lists#

Lists can be joined with the addition operators:

python
even_numbers = [2,4,6,8]
odd_numbers = [1,3,5,7]
all_numbers = odd_numbers + even_numbers
print(all_numbers)

Just as in strings, Python supports forming new lists with a repeating sequence using the multiplication operator:

python
print([1,2,3] * 3)
Exercise

Try it

ready

Get the Python agent pack

A battle-tested AGENTS.md, the review checklist, and the failure-mode cheat sheet for Python. One email, then occasional updates when the tooling shifts. No course pitch.

Unsubscribe in one click. We never sell the list. Or just take the AGENTS.md now — no email needed.