48.3k views
4 votes
What is output? def calc(num1, num2): print(1 + num1 + num2, enda) calc(4,5) calc(1, 2) a. 93 b. 104 O c. 145 112 O d.4,5, 1, 2

1 Answer

2 votes

Hi! The output of the given code with the function calc(num1, num2) is:

The function calc(num1, num2) takes two numbers as input and calculates the sum of 1, num1, and num2. It then prints the result, followed by the value of the variable 'enda'.

However, there's an issue with the code, as 'enda' is not defined. Assuming you meant 'end=' instead of 'enda', the output would be the sums without any spaces or newline characters between them.

Here's a step-by-step explanation:

1. The function calc is defined with parameters num1 and num2.
2. It calculates the sum of 1, num1, and num2.
3. The result is printed with no space or newline character between the outputs.
4. The function is called twice with different arguments: calc(4, 5) and calc(1, 2).

The outputs of the function calls are:
- calc(4, 5): 1 + 4 + 5 = 10
- calc(1, 2): 1 + 1 + 2 = 4

So, the final output will be '104' (option b).

User Helin Wang
by
7.9k points