Mathematical Operations
You can perform arithmetic operations in Python on numeric values. Two The category of data a value belongs to. data types that exist in Python are int and float.
- int: integer numbers, for example, 7.
- float: numbers with a decimal point, for example, 7.5.
And we can use Python’s arithmetic operators to perform common mathematical operations on ints and floats as shown in the table below.
Operation | Operator | Example | Output |
---|---|---|---|
Addition | + | 7 + 5 | 12 |
Subtraction | - | 13.5 - 4 | 9.5 |
Division | / | 72 / 9 | 8.0 |
Floor Division | // | 45 // 9 | 5 |
Multiplication | * | 61 * 4 | 244 |
Exponentiation | ** | 3 ** 3 | 27 |
Modulus | % | 15 % 13 | 2 |
7 multiplied by 5
To calculate 7 multiplied by 5, enter the below code into a code editor:
7 * 5
Output
35
Try performing your own mathematical operations in Python following the guidelines in the table.