Python – Arithmetic Operators

Arithmetic operators are used to perform mathematical operations.

Addition (+): Adds two operands.

a = 5
b = 3
print(a + b)  # Output: 8

Subtraction (-): Subtracts the second operand from the first.

print(a - b)  # Output: 2

Multiplication (*): Multiplies two operands.

print(a * b)  # Output: 15

Division (/): Divides the first operand by the second (floating-point division).

print(a / b)  # Output: 1.6666666666666667

Floor Division (//): Divides the first operand by the second and returns the integer part.

print(a // b)  # Output: 1

Modulus (%): Returns the remainder of the division.

print(a % b)  # Output: 2

Exponentiation (**): Raises the first operand to the power of the second.

print(a ** b)  # Output: 125

Tutorials Deck

TutorialsDeck is striving to provide the best learning material on technical and non-technical subjects.

Languages

Web Technologies

Database

Trending Technologies

© 2024. All rights reserved.

Contact Us @ tutorialsdeck06@gmail.com