Question:

Consider the statements given below and then choose the correct output from the given options:
def Change(N):
    N = N + 10
    print(N, end='$$')

N = 15
Change(N)
print(N)

Show Hint

In Python, integers are immutable,
and changes to function parameters do not affect the original variable.
  • 25$$15
  • 15$$25
  • 25$$25
  • 25 25$$
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

A function named Change is defined that takes N as a parameter.
Inside the function, N is increased by 10 and then printed with `$$` as the ending.
Outside the function, N is initialized as 15.
When Change(N) is called, the local copy of N inside the function becomes 25.
However, this change does not affect the original N outside the function because Python passes integers by value (immutable).
So, when print(N) is called after the function, the original value 15 is printed.
Hence, the output will be `25$$15`.
So, option (A) is the correct answer.
Was this answer helpful?
0
0

Top Questions on Programming in Python

View More Questions

Questions Asked in CBSE CLASS XII exam

View More Questions