Answer:
An input of -5 gives an output of 4
Step-by-step explanation:
Given
The attached program
Required
The output when input is -5
Analyzing the program line by line:
This defines the function tryIt. It gets the parameter from the main method.
So, if the user enters -5, -5 is passed into the function through argument a
def tryIt(a,b=7):
This calculates a + b, and returns the sum to the main: a = -5 and b = 7.
return a + b
So: -5 + 7 = 2; 2 is returned to the main method
The main begins here
#MAIN
This is where you get to input -5
n =int(input("Enter a number: "))
The multiplies the returned value by 2.
ans = tryIt(n)*2
tryIt(-5) = 2. So: ans = 2 * 2; ans = 4
This prints 4
print(ans)