Question:medium

Consider the statements given below and then choose the correct output from the given options:
N = '5'
try:
    print('WORD' + N, end='#')
except:
    print('ERROR', end='#')
finally:
    print('OVER')

Show Hint

The finally block always runs,
regardless of whether an exception occurs or not.
Always use matching data types when concatenating strings.
Updated On: Jan 14, 2026
  • ERROR#
  • WORD5#OVER
  • WORD5#
  • ERROR#OVER
Show Solution

The Correct Option is B

Solution and Explanation

The variable N is initialized as the string `'5'`.
Within the try block, the operation print('WORD' + N, end='#') concatenates the literal string `'WORD'` with the string value of N, which is `'5'`.
This concatenation succeeds because both operands are strings.
Consequently, the string `'WORD5'` is output, followed by the specified terminator character, `#`.
As no exception is raised during the try block's execution, the except block is bypassed.
The finally block executes unconditionally. Therefore, the string `'OVER'` is printed immediately after the try block's output.
The complete output string is `'WORD5#OVER'`.
Based on this analysis, option (B) is identified as the correct choice.
Was this answer helpful?
0