Python Arithmetic Operators
Syntax
Arithmetic operators in Python are used to perform basic mathematical operations like addition, subtraction, multiplication, division, and more.
+ # Adds- # Subtracts* # Multiplies/ # Divides (returns float)// # Divides (returns int)% # Remainder** # Exponentaddition = x + y # Adds x and ysubtraction = x - y # Subtracts y from xmultiplication = x * y # Multiplies x and ydivision = x / y # Divides x by y (returns float)floor_division = x // y # Divides x by y (returns int)modulus = x % y # Remainder of x divided by yexponent = x ** y # x raised to the power of yExample
# Calculating the results of different operationsa = 15b = 4
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"Floor Division: {a} // {b} = {a // b}")print(f"Modulus: {a} % {b} = {a % b}")print(f"Exponentiation: {a} ** {b} = {a ** b}")