Posted in

Python Arithmetic Operators Explained: Complete Guide with Examples

Learn Python Arithmetic Operators through clear explanations, practical examples, real-world use cases, comparison tables, and beginner-friendly guidance. This complete guide covers all seven arithmetic operators, common mistakes, operator precedence basics, and helpful tips to build a strong foundation in Python.
Python Arithmetic Operators explained with symbols, examples, and operator categories in Python
Python Arithmetic Operators include addition (+), subtraction (-), multiplication (*), division (/), floor division (//), modulus (%), and exponentiation (). This guide explains each operator with practical examples and beginner-friendly explanations.**

Introduction: Python Arithmetic Operators

In the previous lesson, you learned what operators are, how they work with operands, the difference between expressions and statements, and the major categories of Python operators. That lesson built the foundation you need before exploring each operator category in detail.

In this lesson, we’ll begin with the Python Arithmetic Operators—the most fundamental and frequently used operators in Python. Whether you’re adding two numbers, calculating a percentage, finding a remainder, or raising a value to a power, arithmetic operators make these mathematical operations possible. They are used in everything from simple calculators and shopping cart totals to scientific applications, data analysis, game development, and machine learning.

Rather than simply memorizing seven operator symbols, this lesson focuses on understanding how, when, and why each arithmetic operator is used. By the end of this lesson, you’ll not only know what each operator does but also understand its behavior, common confusion points, and practical applications in real-world Python programs.

In this lesson, you’ll learn:

  • What Python Arithmetic Operators are and why they are called “arithmetic” operators.
  • Whether arithmetic operators are an official Python language category or a commonly used educational classification.
  • The purpose and behavior of all seven Python arithmetic operators.
  • The syntax, practical examples, and real-world use cases for each operator.
  • How arithmetic operators behave with different Python data types.
  • The basics of arithmetic operator precedence and evaluation order.
  • Common beginner mistakes and how to avoid them.
  • Best practices for writing clear and reliable arithmetic expressions.

Before we understand what Python Arithmetic Operators are, let’s first answer an important question:

Why are they called “Arithmetic Operators” in the first place?


Why Are They Called “Arithmetic Operators” in the First Place?

Before learning what Python Arithmetic Operators are, it helps to understand the meaning behind their name.

The word arithmetic refers to the branch of mathematics that deals with basic numerical calculations, such as addition, subtraction, multiplication, division, finding remainders, and working with powers. These are the same types of calculations we learn in school and use in everyday life—for example, calculating a shopping bill, finding an average, measuring distance, or determining a discount.

Python uses a special set of symbols to perform these mathematical calculations in code. Since these symbols are used for arithmetic operations, they are commonly known as Arithmetic Operators.

For example, when you write an expression like:

total_price = item_price + tax

the + symbol tells Python to perform an arithmetic operation by adding two values together. Similarly, symbols like -, *, /, //, %, and ** instruct Python to perform different kinds of mathematical calculations.

In simple terms:

Arithmetic + Operators = Symbols that perform mathematical calculations.

The name itself is quite descriptive—it tells you both what these symbols do (perform operations) and what kind of operations they perform (arithmetic or mathematical calculations).

However, this raises another interesting question.

If these are called Arithmetic Operators, does that mean Python officially divides its operators into categories such as arithmetic, comparison, logical, assignment, and others? Or are these categories simply a convenient way to organize and teach the language?

Let’s clear up that confusion before we explore the operators themselves.


Are Python Operator Categories Official?

If you’ve searched for Python operators online, you’ve probably noticed that almost every tutorial, book, or course divides them into categories such as:

  • Arithmetic Operators
  • Assignment Operators
  • Comparison Operators
  • Logical Operators
  • Identity Operators
  • Membership Operators
  • Bitwise Operators

This naturally raises an interesting question:

Are these categories officially defined by Python, or are they simply a convenient way to organize the language?

The short answer is:

These categories are a widely accepted educational classification, but they are not formally declared as predefined operator categories in Python’s language specification.

In other words, Python does not have an official statement saying:

“Python operators are divided into these seven categories.”

Instead, the Python language defines each operator individually and explains how it behaves as part of its expression syntax and grammar.


How Does Python Officially Define Operators?

Python’s official language specification describes operators in The Python Language Reference, specifically in Chapter 6: Expressions.

Rather than organizing operators into educational categories, the language reference explains:

  • how expressions are formed,
  • how different operators behave,
  • how Python evaluates expressions,
  • operator precedence,
  • operator associativity,
  • and the exact syntax and semantics of each operator.

This approach is designed for precisely defining the language, rather than teaching it.

Official Reference: The Python Language Reference – Chapter 6: Expressions explains how Python defines expressions, operators, precedence, and evaluation rules. If you’re interested in the formal language specification, it’s an excellent resource to explore alongside this chapter.


Python Language Insight

There is an important difference between how a programming language is specified and how it is taught.

The Python Language Reference focuses on describing the language with technical precision, while books, tutorials, and courses focus on making the language easier to understand.

That’s why educational resources commonly group operators into categories like Arithmetic, Comparison, or Logical Operators. These groupings make learning much more structured and beginner-friendly, even though they are not presented as formal categories in the language specification.


Why Do Almost All Tutorials Use These Categories?

Although the categories are educational in origin, they are grounded in real distinctions.

Each group is based on the primary purpose of its operators.

CategoryPrimary Purpose
Arithmetic OperatorsPerform mathematical calculations
Assignment OperatorsAssign or update values
Comparison OperatorsCompare two values
Logical OperatorsCombine or negate Boolean expressions
Identity OperatorsCheck whether two objects are the same object
Membership OperatorsTest whether a value exists in a collection
Bitwise OperatorsPerform operations on individual bits

Because these purposes are clear and well-defined, this classification has become the standard used throughout the Python community. You’ll find these same categories in most tutorials, books, online courses, and reference materials.


What Approach Will We Follow in This Chapter?

Throughout this chapter, we’ll use these widely accepted operator categories because they provide a clear and logical learning path.

At the same time, whenever appropriate, we’ll also refer to Python’s official language specification so you understand not only how operators are commonly taught, but also how the Python language itself defines and interprets them.

This approach gives you the best of both worlds: a beginner-friendly learning experience backed by an accurate understanding of the language.


Part 1: Arithmetic Operators

Now that we’ve understood why these operators are called Arithmetic Operators and how this category is commonly used throughout the Python community, let’s explore what they actually are and how they work.

Arithmetic operators are among the first operators every Python programmer learns because they are used to perform mathematical calculations. Whether you’re writing a simple calculator, calculating a student’s average marks, processing financial data, or building scientific applications, arithmetic operators allow Python to manipulate numeric values quickly and efficiently.

In this section, we’ll build a solid understanding of what arithmetic operators are, the kinds of calculations they perform, the data types they commonly work with, and a few interesting behaviors that make them more powerful than they might first appear.


1.1 What Are Arithmetic Operators?

Arithmetic operators are special symbols that tell Python to perform mathematical operations on one or more operands (values or variables).

Just as a calculator uses symbols like + and to perform calculations, Python uses arithmetic operators to evaluate mathematical expressions and produce a result.

For example:

number_one = 15
number_two = 5

result = number_one + number_two

print(result)

Output:

In this example:

  • number_one and number_two are the operands.
  • + is the arithmetic operator.
  • Python adds the two values and stores the result in result.

Arithmetic operators allow Python to perform calculations such as:

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Floor division
  • Finding the remainder
  • Raising numbers to a power

These operations form the foundation of numerical programming in Python.


1.2 What Kinds of Calculations Can Arithmetic Operators Perform?

Python provides arithmetic operators for many of the mathematical calculations you perform every day.

Some common examples include:

  • Adding two or more values
  • Subtracting one value from another
  • Multiplying numbers
  • Dividing values
  • Finding the integer (floor) quotient of a division
  • Finding the remainder after division
  • Calculating powers and exponents

These operations are used in countless real-world applications, such as:

  • Calculating shopping totals and discounts
  • Computing percentages and averages
  • Measuring distance, speed, and time
  • Financial calculations
  • Scientific and engineering programs
  • Data analysis and machine learning
  • Games and simulations

Because mathematical calculations appear in almost every type of software, arithmetic operators are among the most frequently used operators in Python.


1.3 Which Data Types Can Be Used with Arithmetic Operators?

Arithmetic operators are primarily designed to work with Python’s numeric data types, allowing you to perform mathematical calculations on numbers. The three main numeric data types that commonly use arithmetic operators are:

  • int – Whole numbers such as 10, -5, and 42
  • float – Decimal (floating-point) numbers such as 3.14, 0.5, and -8.75
  • complex – Complex numbers such as 2 + 3j and 5 - 4j

For example:

whole_number = 20
decimal_number = 3.5
complex_number = 4 + 2j

As a beginner, you’ll work mostly with integers and floating-point numbers, while complex numbers are primarily used in scientific, engineering, and mathematical applications.

Do Arithmetic Operators Work Only with Numbers?

Not always.

Although arithmetic operators are mainly intended for mathematical calculations, Python allows some arithmetic operators to have additional behavior for certain non-numeric data types, such as strings, lists, and tuples.

For example, the + operator can join (concatenate) two strings:

greeting = "Hello"
website_name = " PyCoder"

print(greeting + website_name)

Output:

Similarly, the * operator can repeat a string multiple times:

Output:

Python Python Python

This doesn’t mean that all arithmetic operators work with strings or other non-numeric data types. Only certain operators support these additional behaviors, while others are designed exclusively for numeric calculations.

For now, simply remember that numbers are the primary data types for arithmetic operators, while some operators also support additional behaviors with specific non-numeric data types. We’ll explore these behaviors later in this lesson.


Now that you understand what Python Arithmetic Operators are, the kinds of calculations they perform, and the data types they commonly work with, it’s time to meet all seven arithmetic operators.


Part 2: The Seven Arithmetic Operators (Overview)

Now that you understand what Python Arithmetic Operators are and the kinds of data they commonly work with, let’s take a quick look at all seven arithmetic operators provided by Python.

Each operator performs a specific type of mathematical operation. Some, like addition and multiplication, are familiar from everyday mathematics, while others, such as floor division and modulus, are unique to programming and may be new to many beginners.

The table below provides a quick overview of each operator and its primary purpose.

OperatorNamePrimary PurposeExample
+AdditionAdds two operands together5 + 3
-SubtractionSubtracts one operand from another10 - 4
*MultiplicationMultiplies two operands6 * 7
/DivisionDivides one operand by another and returns the true quotient10 / 4
//Floor DivisionDivides two operands and returns the floor (rounded down) quotient10 // 4
%ModulusReturns the remainder after division10 % 4
**ExponentiationRaises a number to the power of another2 ** 3

At this stage, you don’t need to memorize every operator or worry about how they behave in different situations. The goal is simply to become familiar with the symbols and the type of calculation each one performs.

In the following sections, we’ll explore each arithmetic operator individually, learning its syntax, behavior, practical examples, common confusion points, and real-world use cases.


Visual Recap: The Seven Python Arithmetic Operators

Before we study each operator in detail, take a quick look at this visual summary of all seven Python arithmetic operators. It provides an easy way to recognize each operator and remember its primary purpose at a glance.

Overview infographic of the seven Python Arithmetic Operators showing the addition (+), subtraction (-), multiplication (*), division (/), floor division (//), modulus (%), and exponentiation () operators with their primary purposes.

Now that you have a quick overview of all seven Python Arithmetic Operators, let’s explore each one individually, beginning with the most fundamental operator—the Addition (+) operator.


Part 3: The Addition (+) Operator

The addition operator (+) is one of the most frequently used operators in Python. Its primary purpose is to add two numeric values and return their sum.

If you’ve ever used a calculator to add numbers, the Python addition operator works in the same way.

Although the addition operator is primarily used for mathematical calculations, Python also gives it additional meanings for certain data types, such as joining strings and combining lists. We’ll briefly look at these behaviors later in this section.


3.1 What Does the Addition Operator Do?

The addition operator tells Python to add two operands together.

These operands are usually numbers, but depending on the data type, the + operator can perform different operations.

For numeric values:

  • int + int
  • int + float
  • float + float
  • complex + complex

the operator performs mathematical addition.

For example:

first_number = 15
second_number = 8

result = first_number + second_number

print(result)

Output

Python first evaluates the expression first_number + second_number, then stores the result in the variable result.


3.2 Syntax

The general syntax of the addition operator is:

where:

  • operand1 is the first value.
  • + is the addition operator.
  • operand2 is the second value.

Python evaluates the expression and returns the sum of both operands.


3.3 Basic Examples

Adding two integers

number_one = 12
number_two = 5

print(number_one + number_two)

Output

Adding floating-point numbers

price = 19.95
tax = 2.50

print(price + tax)

Output

Adding an integer and a float

whole_number = 10
decimal_number = 2.5

print(whole_number + decimal_number)

Output

Notice that Python returns a float because one operand is a floating-point number.

Adding a Positive Sign (Unary +)

The + operator can also be used as a unary operator, meaning it operates on a single operand.

For example:

number = +10

print(number)

Output

In this case, the unary + simply indicates that the value is positive, unary + does not modify the value—it simply returns the operand unchanged.

Because positive numbers are assumed by default, you’ll rarely see unary + used in everyday Python code. Nevertheless, it’s part of the language and demonstrates that the same symbol can act as either a binary operator or a unary operator, depending on how it’s used.


3.4 Real-World Example

Suppose you’re building an online shopping application.

You want to calculate the total amount a customer has to pay before tax.

laptop_price = 65000
mouse_price = 1200
keyboard_price = 1800

total_price = laptop_price + mouse_price + keyboard_price

print(total_price)

Output

This is exactly how addition operators are used in real applications—combining multiple values to produce a final result.


3.5 The Addition Operator with Strings

As mentioned earlier in this lesson, Python allows the addition operator to perform string concatenation.

Instead of adding numbers, Python joins the two strings into a single string.

first_name = "PyCoder"
last_name = "Hub"

print(first_name + last_name)

Output

If you want a space between the words, include it in one of the strings:

first_name = "PyCoder"
last_name = " Hub"

print(first_name + last_name)

Output

This behavior is known as string concatenation.

We’ll study string concatenation in much greater detail when we cover Python strings. For now, simply remember that the + operator has an additional meaning when used with string operands.


3.6 Common Beginner Mistakes

Mixing incompatible data types

A common mistake is trying to add a string and a number.

age = 25

print("Age: " + age)

This raises an error because Python cannot automatically add a string and an integer.

TypeError: can only concatenate str (not "int") to str

To fix this, convert the number to a string:

age = 25

print("Age: " + str(age))

Output

Note: If you’re unfamiliar with converting values between different data types, see our Python Type Casting chapter, where you’ll learn how functions like str(), int(), and float() convert values from one type to another with practical examples.


Key Takeaways

  • The + operator primarily performs mathematical addition.
  • It returns the sum of two numeric operands.
  • It works with Python’s numeric data types, including int, float, and complex.
  • Python also uses + to concatenate strings and combine certain sequence types.
  • Mixing incompatible data types, such as a string and an integer, raises a TypeError.

Part 4: The Subtraction (-) Operator

The subtraction operator (-) is used to subtract one operand from another and return the difference between them. Like the addition operator, subtraction is one of the most commonly used arithmetic operations in Python and is widely used in everyday programming.

For example, you might use subtraction to:

  • Calculate a discount on a product.
  • Determine the remaining account balance after a withdrawal.
  • Find the difference between two temperatures.
  • Calculate profit or loss.
  • Measure the time or distance between two events.

Whenever you need to determine how much one value differs from another, the subtraction operator is the appropriate choice.


4.1 What Does the Subtraction Operator Do?

The subtraction operator tells Python to subtract the second operand from the first operand.

The general syntax is:

Python evaluates the expression and returns the difference.

For example:

first_number = 20
second_number = 8

result = first_number - second_number

print(result)

Output

In this example:

  • 20 is the first operand.
  • 8 is the second operand.
  • Python subtracts 8 from 20 and returns 12.

4.2 Basic Examples

Subtracting Two Integers

current_score = 95
penalty_points = 10

final_score = current_score - penalty_points

print(final_score)

Output:

Subtracting Floating-Point Numbers

original_price = 99.99
discount = 15.50

print(original_price - discount)

Output:

Subtracting Different Numeric Types

Arithmetic operators work naturally with different numeric data types.

whole_number = 25
decimal_number = 4.5

print(whole_number - decimal_number)

Output:

Subtracting a Larger Number from a Smaller Number

If the second number is larger than the first, Python returns a negative value.

available_balance = 20
purchase_amount = 35

print(available_balance - purchase_amount)

Output:


4.3 Unary Minus (-)

The subtraction symbol (-) can also be used as a unary operator, meaning it operates on a single operand instead of two.

When used this way, it changes the sign of a number.

For example:

temperature = -12

print(temperature)

Output:

Notice the difference between the unary + and unary - operators: unary + leaves the value unchanged (so no + sign appears in the output), whereas unary - changes the value to its negative form, so the output includes a minus (-) sign.

You can also apply unary minus to an existing value:

number = 18

print(-number)

Output:

Unlike binary subtraction, which calculates the difference between two operands, unary minus simply returns the negative form of a single operand.

This is another example of how the same symbol can act as either a binary operator or a unary operator, depending on how it is used.


4.4 Real-World Example

Suppose you’re developing a simple banking application.

A customer has a balance of ₹15,000 and withdraws ₹3,500.

account_balance = 15000
withdrawal_amount = 3500

remaining_balance = account_balance - withdrawal_amount

print(remaining_balance)

Output:

Subtraction operators are commonly used whenever values need to be reduced, adjusted, or compared.


4.5 Common Beginner Mistakes

Reversing the Operands

Remember that subtraction is not commutative, which means changing the order of the operands changes the result.

For example:

print(15 - 5)
print(5 - 15)

Output:

Although both expressions use the same numbers, they produce different results because Python always subtracts the second operand from the first operand.

Expecting Subtraction to Work with Strings

Unlike the addition operator, the subtraction operator cannot be used with strings.

For example:

first_name = "Py"
last_name = "Coder"

print(first_name - last_name)

Python raises:

TypeError: unsupported operand type(s) for -: 'str' and 'str'

The subtraction operator is designed for numeric calculations only. It does not support string subtraction or other sequence operations.


Key Takeaways

  • The - operator subtracts one operand from another.
  • It works with Python’s numeric data types, including int, float, and complex.
  • The order of operands matters because subtraction is not commutative.
  • The same symbol also acts as a unary operator, allowing you to represent or produce negative values.
  • Unlike the addition operator, subtraction does not support operations such as string concatenation.

Part 5: The Multiplication (*) Operator

The multiplication operator (*) is used to multiply two operands and return their product. Like addition and subtraction, it’s one of the most commonly used arithmetic operators in Python and appears in programs ranging from simple calculations to scientific computing and data analysis.

Beyond basic multiplication, Python gives the * operator an additional role with certain non-numeric data types, such as repeating strings and other sequences. We’ll see both behaviors in this section.


5.1 What Does the Multiplication Operator Do?

The multiplication operator tells Python to multiply two operands together.

The general syntax is:

Python evaluates the expression and returns the product.

For example:

first_number = 8
second_number = 6

result = first_number * second_number

print(result)

Output:

In this example:

  • 8 is the first operand.
  • 6 is the second operand.
  • Python multiplies both values and returns 48.

5.2 Basic Examples

Multiplying Two Integers

rows = 12
columns = 5

total_cells = rows * columns

print(total_cells)

Output:

Multiplying Floating-Point Numbers

length = 5.5
width = 3.2

print(length * width)

Output:


5.3 Real-World Example

Suppose you’re creating an online shopping application.

A customer purchases three wireless headphones, each costing ₹2,499.

price_per_headphone = 2499
quantity = 3

total_price = price_per_headphone * quantity

print(total_price)

Output:

Multiplication is commonly used to calculate totals, areas, volumes, salaries, interest, and many other quantities where one value is repeated multiple times.


5.4 The Multiplication Operator with Strings

As mentioned earlier in this lesson, Python allows the multiplication operator to work with certain non-numeric data types.

When a string is multiplied by an integer, Python repeats the string the specified number of times.

For example:

Output:

Python Python Python

This behavior is known as string repetition.

You can also use it to create simple patterns.

Output:

Similarly, the * operator also supports repetition with other sequence data types, such as lists and tuples.


5.5 Common Beginner Mistakes

Multiplying Two Strings

A common misconception is that two strings can be multiplied together.

For example:

first_word = "Py"
second_word = "Coder"

print(first_word * second_word)

Python raises:

TypeError: can't multiply sequence by non-int of type 'str'

The multiplication operator only supports string × integer, not string × string.

Using a Floating-Point Number for Repetition

The repetition count must be an integer.

print("Python " * 2.5)

Python raises:

TypeError: can't multiply sequence by non-int of type 'float'

This doesn’t work because Python needs an exact whole number to determine how many times to repeat the sequence, and a floating-point value can represent fractional amounts.


Key Takeaways

  • The * operator multiplies two numeric operands and returns their product.
  • It works with Python’s numeric data types, including int, float, and complex.
  • Python also allows string × integer to repeat a string multiple times.
  • The repetition count must be an integer.
  • The multiplication operator does not support multiplying one string by another.

Hi, I’m Ankur, the creator of PyCoderHub. I document my Python learning journey in a structured, beginner-friendly way to make concepts clear and easy to follow.

Each post is carefully researched, cross-checked, and simplified to ensure accurate explanations. If you’re learning Python, you can follow along step by step—and if you’re experienced, your feedback is always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *