Basic operators

Aside from assigning a variable, we can perform mathematical operations on variables. Some of the basic operators include:

multiplication → *
division → /
addition → +
subtraction → -
floor division → //
modulus → %
exponent → **


An example includes:

x = 5, y = 2

x*y = 10
x/y = 2.5
x + y = 7
x - y = 3
x//y = 2 (rounds down answer to nearest whole number)
x%y = 1 (remainder from 5/2)
x**y = 25 (5^2)

No comments:

Post a Comment