0
0
Pythonprogramming~5 mins

Arithmetic operators in Python

Choose your learning style9 modes available
Introduction

Arithmetic operators help us do math with numbers in programs. They let us add, subtract, multiply, and divide easily.

Calculating the total price of items in a shopping cart.
Finding the difference in days between two dates.
Doubling a recipe ingredient amount.
Splitting a bill evenly among friends.
Converting temperatures between Celsius and Fahrenheit.
Syntax
Python
result = a + b  # addition
result = a - b  # subtraction
result = a * b  # multiplication
result = a / b  # division
result = a % b  # remainder (modulus)
result = a ** b # power (exponent)
result = a // b # floor division (whole number division)

Use + to add numbers.

Use - to subtract one number from another.

Examples
Adds 5 and 3, then prints 8.
Python
x = 5 + 3
print(x)
Subtracts 4 from 10, then prints 6.
Python
y = 10 - 4
print(y)
Multiplies 7 by 2, then prints 14.
Python
z = 7 * 2
print(z)
Divides 15 by 4, prints 3.75 (a float).
Python
a = 15 / 4
print(a)
Sample Program

This program shows all main arithmetic operations between 12 and 5 with clear labels.

Python
a = 12
b = 5
print(f"Addition: {a} + {b} = {a + b}")
print(f"Subtraction: {a} - {b} = {a - b}")
print(f"Multiplication: {a} * {b} = {a * b}")
print(f"Division: {a} / {b} = {a / b}")
print(f"Modulus: {a} % {b} = {a % b}")
print(f"Power: {a} ** {b} = {a ** b}")
print(f"Floor Division: {a} // {b} = {a // b}")
OutputSuccess
Important Notes

Division / always gives a float result, even if numbers divide evenly.

Floor division // gives the whole number part of division, dropping decimals.

Modulus % gives the remainder after division.

Summary

Arithmetic operators let you do basic math in code.

Use +, -, *, / for add, subtract, multiply, divide.

Other useful operators: % (remainder), ** (power), // (floor division).