# Function to add two numbers
def add(x, y):
return x + y
# Function to subtract y from x
def subtract(x, y):
return x - y
# Function to multiply two numbers
def multiply(x, y):
return x * y
# Function to divide x by y
def divide(x, y):
if y != 0:
return x / y
else:
return "Error: Division by zero"
# Example usage:
# Taking input from the user for two numbers
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# Performing arithmetic operations and printing the results
print("Sum:", add(num1, num2)) # Adding num1 and num2
print("Difference:", subtract(num1, num2)) # Subtracting num2 from num1
print("Product:", multiply(num1, num2)) # Multiplying num1 and num2
# Handling division and printing the result
print("Quotient:", divide(num1, num2)) # Dividing num1 by num2, handling division by zero
Output 1:
Enter first number: 10
Enter second number: 5
Sum: 15.0
Difference: 5.0
Product: 50.0
Quotient: 2.0
Output 2:
Enter first number: 25
Enter second number: 0
Sum: 25.0
Difference: 25.0
Product: 0.0
Quotient: Error: Division by zero