Advertisements
Advertisements
Question
Write the output of the code given below:
a = 30
def call (x):
global a
if a%2==0:
x+=a
else:
x−=a
return x
x=20
print (call (35), end="#")
print (call (40), end="@")Short Answer
Advertisements
Solution
Output:
65#70@
Explanation:
The call() method examines the value of the global variable a. Because a is 30 and 30 % 2 returns 0 in both function calls, the expression x+=a is executed, resulting in the numbers 30 + 35 and 30 + 40 in the respective calls.
shaalaa.com
Is there an error in this question or solution?
