Course Content
Computer Science 2010 : Olevel : Free Trail Course

Arithmetic operators in programming are symbols or functions that perform mathematical operations on operands. These operators include addition (+), subtraction (-), multiplication (*), division (/), modulus (%), and exponentiation (**). Here’s how each operator works with examples:

Addition (+): Adds two operands(values)

a = 5
b = 3
result = a + b # result will be 8

Subtraction (-): Subtracts the right operand from the left operand.

a = 10
b = 4
result = a – b # result will be 6

Multiplication (*): Multiplies two operands.

a = 6
b = 7
result = a * b # result will be 42

Division (/): Divides the left operand by the right operand (results in a float).

a = 10
b = 3
result = a / b # result will be 3.3333333333333335

Modulus (%): Returns the remainder of the division of the left operand by the right operand.

a = 10
b = 3
result = a % b # result will be 1

Exponentiation ():** Raises the left operand to the power of the right operand.

a = 2
b = 3
result = a ** b # result will be 8

These arithmetic operators are fundamental in programming and are used extensively for performing mathematical calculations in various applications. It’s essential to understand their behavior and precedence rules when writing programs to ensure correct and efficient computation.