Return multiple values from a function

Write a program to create function `calculation()`

such that it can accept two variables and calculate addition and subtraction. Also, it must **return both addition and subtraction in a single return call**.

Return multiple values from a function

Write a program to create function `calculation()`

such that it can accept two variables and calculate addition and subtraction. Also, it must **return both addition and subtraction in a single return call**.

1 Like

def calculation(a, b):

addition = a + b

subtraction = a - b

```
return addition, subtraction
```

result = calculation(10, 5)

print(f"Addition result: {addition}β)

print(f"Subtraction result: {subtraction}β)

1 Like

def calculation(x,y):

add_value=x+y

sub_value=x-y

return add_value,sub_value

x=int(input())

y=int(input())

print(calculation(x,y)

1 Like

Good. Please check on your print statement

Vey good. Keep working on

def calculate(a, b):

addition_result = a + b

subtraction_result = a - b

return addition_result, subtraction_result

num1 = int(input("Enter the first number: "))

num2 = int(input(βEnter the second number: β))

addition, subtraction = calculate(num1, num2)

print(f"Addition: {num1} + {num2} = {addition}β)

print(f"Subtraction: {num1} - {num2} = {subtraction}β)

Very good .keep trying

```
def calculation(num1,num2):
addition=num1+num2
subtraction=num1-num2
return print(f'addition: {addition}\nsubtraction: {subtraction}')
num1=int(input("enter first number:"))
num2=int(input("enter second number:"))
calculation(num1,num2)
```

1 Like

very good. keep practicing