CBSE · 083Class XII · 2023Section B2 marks

Question 24(2)

30 March 2023 · Computer Science (083)

Write the output of the code given below :

python
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="@")

Answer

text
65#70@

Explanation

a = 30 is even, so x += a is taken in both calls. First call: 35 + 30 = 65, printed with '#'. Second call: 40 + 30 = 70, printed with '@'.