Master Python Arithmetic Operators with Simple Examples

Arithmetic operators in Python play a fundamental role in performing calculations and operations on numerical data. They allow you to perform tasks such as addition, subtraction, multiplication, and division, among others. By understanding and utilizing these operators effectively, you can streamline your coding process and make your programs more efficient.

Python Arithmetic Operators
Python Arithmetic Operators

Python provides a variety of arithmetic operators, each serving a specific purpose. In this article, we will explore the different types of arithmetic operators in Python, along with examples to help clarify their usage.

Python arithmetic operators cheat-sheet
Python arithmetic operators cheat-sheet

Arithmetic Operator Types

Python offers six primary arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), floor division (//), and modulus (%). Each operator has a specific functionality and can be used in various programming scenarios.

Python Operators Explained for Beginners
Python Operators Explained for Beginners

In addition to the primary operators, Python also supports the use of assignment operators, which combine an arithmetic operator with an assignment operator (=). Examples include += (add and assign), -= (subtract and assign), *= (multiply and assign), and /= (divide and assign). These operators allow for concise and efficient mathematical operations in Python.

Addition Operator (+)

Python Arithmetic Operators
Python Arithmetic Operators

The addition operator (+) is used to add two numbers together. It can operate on both integers and floating-point numbers (or float). Here's an example that demonstrates the usage of the addition operator:

```python num1 = 5 num2 = 7 result = num1 + num2 print(result) # Output: 12 ```

In this example, the addition operator is used to add the values of num1 and num2 together, resulting in 12.

Python Operators Tutorial – Chapter 3 Notes
Python Operators Tutorial – Chapter 3 Notes

Subtraction Operator (-)

The subtraction operator (-) is used to find the difference between two numbers. It also serves as a unary operator to negate the value of a number. Here's an example showcasing both uses of the subtraction operator:

```python num1 = 10 num2 = 3 result = num1 - num2 # Subtraction of two numbers print(result) # Output: 7 num = 15 result = -num # Negation of a number print(result) # Output: -15 ```

Python Assignment Operators
Python Assignment Operators

In this example, the subtraction operator is first used to calculate the difference between num1 and num2. Then, it's employed as a unary operator to negate the value of num.

Other Arithmetic Operators

Python Operators 😎✨
Python Operators 😎✨
JavaScript Operators | part 2 | Simply explained Arithmetic operators and Assignment operators 📖 🚀
JavaScript Operators | part 2 | Simply explained Arithmetic operators and Assignment operators 📖 🚀
Types of Operators in Python
Types of Operators in Python
PYTHON OPERATORS
PYTHON OPERATORS
Logical Operators in Python with Examples Comprehensive Guide
Logical Operators in Python with Examples Comprehensive Guide
Python Operators Cheat Sheet
Python Operators Cheat Sheet
Python arithmetic operators infographic
Python arithmetic operators infographic
Operators in Python
Operators in Python
Python Operators Explained 🐍
Python Operators Explained 🐍
Coding For Beginners Python - Learn the Basics - Operators
Coding For Beginners Python - Learn the Basics - Operators
Math Operators in Python
Math Operators in Python
Python operators infographic with cartoon elements
Python operators infographic with cartoon elements
a diagram with the words python operators on it
a diagram with the words python operators on it
Operators Explained for Beginners
Operators Explained for Beginners
Python operators cheat sheet infographic
Python operators cheat sheet infographic
Python - Basic Operators: Types of Operator
Python - Basic Operators: Types of Operator
Day 3 – Operators | 10 Days Python Challenge
Day 3 – Operators | 10 Days Python Challenge
Python Cheat Sheet for Beginners 2026 | Python Basics, Syntax, Loops, Functions & Variables
Python Cheat Sheet for Beginners 2026 | Python Basics, Syntax, Loops, Functions & Variables
Python Sys Argv in Simple Words with Examples
Python Sys Argv in Simple Words with Examples
Python Learning Path for Beginners 2026 🚀
Python Learning Path for Beginners 2026 🚀

Python provides four additional arithmetic operators: multiplication (*), division (/), floor division (//), and modulus (%). Each of these operators serves a specific mathematical purpose.

You can use these operators to perform various calculations, such as finding products, quotients, remainders, or the largest integer part of a division result. Let's explore each operator with an example:

Multiplication Operator (*)

The multiplication operator (*) is used to multiply two numbers together. It can operate on both integers and floating-point numbers. Here's an example demonstrating the use of the multiplication operator:

```python num1 = 4 num2 = 6 result = num1 * num2 print(result) # Output: 24 ```

In this example, the multiplication operator is used to calculate the product of num1 and num2.

Division Operator (/)

The division operator (/) is used to divide one number by another.When the division involves integers, the result will be an integer without a decimal. If at least one of the operands is a float, the result will be a float. Here's an example showcasing the behavior of the division operator with integers and floats:

```python num1 = 10 num2 = 3 result = num1 / num2 # Integers, result is an integer print(result) # Output: 3 num1 = 10.0 result = num1 / num2 # Float operand, result is a float print(result) # Output: 3.3333333333333335 ```

In this example, the division operator first divides two integers, resulting in an integer. Then, it divides a float by an integer, producing a float as the result.

Floor Division Operator (//)

The floor division operator (//) is used to perform division and round the result down to the nearest whole number. It works only with integers. Here's an example illustrating the usage of the floor division operator:

```python num1 = 7 num2 = 3 result = num1 // num2 print(result) # Output: 2 ```

In this example, the floor division operator divides num1 by num2 and rounds the result down to the nearest whole number, producing 2.

Modulus Operator (%)

The modulus operator (%) is used to find the remainder of a division operation. It only works with integers. Here's an example demonstrating the use of the modulus operator:

```python num1 = 13 num2 = 3 result = num1 % num2 print(result) # Output: 1 ```

In this example, the modulus operator finds the remainder when num1 is divided by num2, resulting in 1.

Understanding and effectively using arithmetic operators in Python is essential for writing efficient and compact code. By mastering these operators, you can streamline your programs and make them more powerful. Keep practicing and experimenting with these operators to solidify your understanding and unlock new coding possibilities.

Related Articles

Python 3 Lambda Example Python W3schools Loops Scikit Learn Library In Python W3schools Nested While Loop In Python W3schools Python3 List Comprehension Examples Nested Loop Python Explained Difference Between List And Tuple In Python W3schools Python W3 Math Nlp Python Example W3schools Python Length