Python Arithmetic Operators
Table of Contents
Description
Arithmetic operators are used in Python to perform basic mathematical operations on numeric values like integers, floats, and complex numbers.
Python supports the following arithmetic operators:
Operator Description Symbol
Addition Adds two values +
Subtraction Subtracts right from left -
Multiplication Multiplies two values \*
Division Divides left by right /
Floor Division Returns integer part //
Modulus Returns remainder %
Exponentiation Raises to power \*\*
Prerequisites
- Familiarity with Python syntax.
- Basic understanding of numbers and variables.
Examples
Here's a simple program in Python:
# Arithmetic Operators in action a = 10 b = 3 # Addition print(a + b) # Output: 13 # Subtraction print(a - b) # Output: 7 # Multiplication print(a \* b) # Output: 30 # Division print(a / b) # Output: 3.333... # Floor Division (ignores decimal part) print(a // b) # Output: 3 # Modulus (remainder) print(a % b) # Output: 1 # Exponentiation print(a \*\* b) # Output: 1000 (10 to the power of 3)
Real-World Applications
Finance: Calculating interest, tax, and balance updates.
Gaming: Scoring, leveling, damage calculations.
E-commerce: Discount, GST, final price calculations.
Data Science: Mathematical operations on datasets.
IoT: Sensor calculations like average temperature, total voltage.
Where topic Can Be Applied
Backend development: Price calculations, usage billing.
ML/AI algorithms: Cost functions, gradient descent.
Scientific computing: Simulations, modeling equations.
School/college apps: Auto evaluation of answers.
Automation scripts: Time and unit conversions
Resources
Topic video source
A comprehensive video
Python pdf
pdf on topic
Interview Questions
What is the difference between / and //?
How does Python handle mixed-type arithmetic (e.g., int + float)?
What does \*\* do in Python?
Which operator returns only the remainder?
What will be the result of 10 // 3 and 10 % 3?