ARITHMETIC OPERATIONS
DIVISION
Division arithmetic operation is used to perform calculations that involve dividing one number by another. In Python, this includes true division using the / operator, which returns a floating-point result, and floor division using the // operator, which returns the largest integer less than or equal to the result, discarding any fractional part. The modulus operator % is also related, providing the remainder after division. These operations are essential for numerical computations, determining ratios, and handling integer-based logic in Python programs.
#!/usr/bin/env python3
def main() -> None:
integerA = 6;
integerB = 3;
#floating point division
print(a / b);
#floor division
print(a // b);
if __name__ == "__main__":
main();
* OUTPUT:
2.0
2EXPONENTIATION
Exponentiation arithmetic operation is used to raise a number to the power of another number. In Python, this is performed using the ** operator, where the left operand is the base and the right operand is the exponent. For example, 2 ** 3 evaluates to 8, as 2 is raised to the power of 3. Exponentiation supports both integer and floating-point numbers, allowing calculations of squares, cubes, roots, and more complex powers. This operation is fundamental in mathematical computations, scientific calculations, and algorithms that require growth modeling, repeated multiplication, or power-based scaling.
#!/usr/bin/env python3
def main() -> None:
integerA = 6;
integerB = 3;
print(a ** b);
if __name__ == "__main__":
main();
* OUTPUT:
216
- In this example, 6 to the power of 3 is 216Last updated