Skip to the content.

3.3 Hw_ipynb_2_

# Function to add two parameters
def add(a, b):
    return a + b

# Function to subtract two parameters
def subtract(a, b):
    return a - b

# Function to divide two parameters
def divide(a, b):
    # To avoid division by zero
    if b == 0:
        return "Division by zero is not allowed"
    return a / b

# Function to find the modulus of two parameters
def modulus(a, b):
    return a % b

# Function to raise 'a' to the power of 'b'
def power(a, b):
    return a ** b

# Example usage:
print(add(10, 5))          # 15
print(subtract(10, 5))     # 5
print(divide(10, 2))       # 5.0
print(divide(10, 0))       # Division by zero is not allowed
print(modulus(10, 3))      # 1
print(power(2, 3))         # 8
15
5
5.0
Division by zero is not allowed
1
8