For question 1-3, consider the following program: def tryIt(a ,b = 7) return a + b

#MAIN
n = int(input(‘Enter a number ‘))
Ans = tryIt(n) * 2
Print (ans)

1. What is output of the user enters 2?


2. What is output if the user enters -5?

3. What is output if the user enters 7?

Answer :

Answer:

1)18

2)4

3)28

Explanation:

1) ans= tryIt(2) *2

        = (2+7)* 2 =18

2) ans= tryIt(-5) *2

        = (-5+7)* 2 =4

3) ans= tryIt(7) *2

        = (7+7)* 2 =28

MrRoyal

Functions are collections of code statements that are executed when called

  • The output when the user enters 2 is 18
  • The output when the user enters -5 is 4
  • The output when the user enters 7 is 28

The given function initializes variable b to 7, and returns the sum of b (i.e. 7) and the value passed to the function.

However; in the main function, the sum is doubled before printed.

So, the computations are as follows:

[tex]f(2) = (2 + 7) \times 2 = 18[/tex]

[tex]f(-5) = (-5 + 7) \times 2 = 4[/tex]

[tex]f(7) = (7 + 7) \times 2 = 28[/tex]

Hence, the outputs for 1 - 3 are 18, 4 and 28, respectively

Read more about functions at:

https://brainly.com/question/25647517