Apple
Banana
Grape
Watermelon
Cherry
Strawberry
Blueberry
Name: Kaiyu
Age: 16
Grade: C
1
12
123
1234
12345
123456
1234567
12345678
123456789
#Program with a Function to perform mathematical and/or a statistical calculations
def add_numbers(a, b):
return a + b
def subtract_numbers(a, b):
return a - b
def multiply_numbers(a, b):
return a * b
def divide_numbers(a, b):
if b == 0:
return "Error: Division by zero is not allowed."
return a / b
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
operation = input("Choose operation (+ for addition, - for subtraction, * for multiplication, / for division): ")
if operation == '+':
result = add_numbers(num1, num2)
operation_symbol = "addition"
elif operation == '-':
result = subtract_numbers(num1, num2)
operation_symbol = "subtraction"
elif operation == '*':
result = multiply_numbers(num1, num2)
operation_symbol = "multiplication"
elif operation == '/':
result = divide_numbers(num1, num2)
operation_symbol = "division"
else:
result = "Invalid operation"
operation_symbol = ""
if operation_symbol:
print(f"{num1} {operation} {num2} = {result} (Operation: {operation_symbol})")
else:
print(result)
5.0 - 5.0 = 0.0 (Operation: subtraction)
The weight in kilograms is 226.76