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')
- A.
ERROR#
- B.
WORD5#OVER
- C.
WORD5#
- 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.