its asking me : Write a function named `average()`

that has two parameters named `num1`

and `num2`

.

The function should return the average of these two numbers.

My answer

# Write your average function here:

def average(num1, num2):

return num1 + num2 / 2

# Uncomment these function calls to test your average function:

print(average(1, 100))

# The average of 1 and 100 is 50.5

print(average(1, -1))

# The average of 1 and -1 is 0

when I run I get 51.0 and 0.5

The solution is

# Write your average function here:

def average(num1, num2):

return (num1 + num2) / 2

# Uncomment these function calls to test your average function:

print(average(1, 100))

# The average of 1 and 100 is 50.5

print(average(1, -1))

# The average of 1 and -1 is 0

On the Return function the only difference from my answer and the correct answer is the parenthesis.

wrong

return num1 + num2 / 2

correct

return (num1 + num2) / 2

I guess my question is why would i get a different average just because of the parenthesis