Untitled

mail@pastecode.io avatar
unknown
python
a year ago
946 B
2
Indexable
Never
# Part 1: Addition and Subtraction
# Input two numbers from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

# Calculate addition and subtraction
addition_result = num1 + num2
subtraction_result = num1 - num2

# Display the results
print(f"Addition result: {num1} + {num2} = {addition_result}")
print(f"Subtraction result: {num1} - {num2} = {subtraction_result}")

# Part 2: Multiplication and Division
# Input two numbers from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

# Check if num2 is not zero to avoid division by zero error
if num2 != 0:
    multiplication_result = num1 * num2
    division_result = num1 / num2
    print(f"Multiplication result: {num1} * {num2} = {multiplication_result}")
    print(f"Division result: {num1} / {num2} = {division_result}")
else:
    print("Error: Division by zero is not allowed.")