English

What will be the output of the following Python code? i = 5 print(i,end='@@') def add(): global i i = i+7 print(i,end='##') add() print(i) - Computer Science (Python)

Advertisements
Advertisements

Question

What will be the output of the following Python code?

i = 5
print(i,end='@@')
def add():
  global i
  i = i+7
  print(i,end='##')
add()
print(i)

Options

  • 5@@12##15

  • 5@@5##12

  • 5@@12##12

  • 12@@12##12

MCQ
Advertisements

Solution

5@@12##12

Explanation:

i starts as 5, printed first → 5@@.
Inside the function, i becomes 12 (global change) → prints 12##.
Finally, printing i again shows 12 → output 5@@12##12.

shaalaa.com
  Is there an error in this question or solution?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×