Home » Programming Language (coding) » Python MCQ » What is the output of the following? try: if ‘1’ != 1: raise “someError” else: print(“someError has not occurred”) except “someError”: print (“someError has occurred”)

What is the output of the following? try: if ‘1’ != 1: raise “someError” else: print(“someError has not occurred”) except “someError”: print (“someError has occurred”)

What is the output of the following?

try:
    if '1' != 1:
        raise "someError"
    else:
        print("someError has not occurred")
except "someError":
    print ("someError has occurred")

A. someError has occured
B. someError has not occured
C. invalid code
D. none of the mentioned

Answer: C. invalid code

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
18 ⁄ 6 =