Consider the Python code below and choose the correct output: N = '5' try:…

2025

Consider the Python code below and choose the correct output:

N = '5'
try:
   print('WORD' + N, end='#')
except:
   print('ERROR', end='#')
finally:
   print('OVER')

  1. A.

    ERROR#

  2. B.

    WORD5#OVER

  3. C.

    WORD5#

  4. D.

    ERROR#OVER

Attempted by 791 students.

Show answer & explanation

Correct answer: B

N is assigned the string value '5'. Therefore, 'WORD' + N performs valid string concatenation and prints WORD5. Because end='#' is used, the # is printed without a newline.

The except block is skipped because no exception occurs. The finally block always executes and prints OVER.

So the final output is:
WORD5#OVER

Therefore, option B is correct.

Explore the full course: Bpsc