Introduction
This is a documentation page for basic operators in the high-level programming language Python.
This page will cover five basic arithmetic operators, namely Addition(+), Subtraction(-), Multiplication(*), Division(/), and Modulo(%).
- Prerequisites
- Basic understanding of math
- Beginner level knowledge of Python
Addition
When using the addition operator with two numbers, you obtain a result that is the sum of both numbers.
x = 5
y = 7
x + y = 12
As can be seen, the sum of both variables 5 and 7 is 12.
Subtraction
When using the subtraction operator with two numbers, you obtain a result that is the value of the first number minus the second.
7 - 5 = 2
As can be seen, the subtraction of 5 from 7 is 2.
Multiplication
When using the multiplication operator with two numbers, you obtain a result that is the multiplied value of both numbers.
7 * 5 = 35
As can be seen, when multiplied the result is 35.
- Breakdown
- 7 * 5 = 35
- (7 + 7 + 7 + 7 + 7) = 35
Division
When using the division operator with two numbers, you obtain a result that is the divided value of both numbers.
35 / 5 = 7
As can be seen, when 35 is divided by 5 the result is 7.
- Breakdown
- 35 / 5 = 7
- 35 = 5 * 7
Modulo
When using the modulo operator with two numbers, you obtain a result that is the remainder of the result after diviing both numbers.
7 % 5 = 2
As can be seen, when 7 is divided by 5 the result is 1 with a remainder of 2, in which 2 is the modulo result.
- Breakdown
- 7 / 5 = 1 R.2
- Modulo = 2
- 7 % 5 = 2