Python Basics
Variables & Comments Math Operators Sequence Data Types Strings Lists & Tuples Logical Operators Conditional Statements Loops Functions
Data Wrangling
Pandas Introduction Importing Data Select, Drop & Rename Joining Data Cleaning Data Add Columns Dates
Coming Soon
Machine Learning
Coming Soon
Other Tutorials & Content
Python Data Science Reference Blog

Python Math Operators

Now that we know how to assign values to variables we can now use Pythons math operators to make calculations with these variables. Let's start by defining some numeric variables and then performing some math operations with them.

a = 2
b = 5
c = 10
d = 17

Python Addition

a + b
> 7

Python Subtraction

c - a
> 8

Python Multiplication

a * c
> 20

Python Division

c * b
> 2.0

Python Raising to a Power

c ** 2
> 100

Python Remainder Operator

The Python remainder or Modulo operator calculates the value left over after dividing the number or variable on the left with the number or variable on the left.

d % c
> 7

Python Floored Quotient Operator

The Python Floored Quotient operator calculates how many times the number or variable on the right goes into the number or variable on the left, rounded down the closest integer.

d // c
> 1