Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 10

What is true about the following snippet? (Choose two.)

    Correct Answer: B, D

    The given code snippet first executes the `print(

Discussion
DKAT2023Options: BD

first D will see , after B will see

kstrOptions: AD

AD CODE: class E(Exception): def __init__(self, message): self.message = message def __str__(self): return "It's nice to see you" try: print("I feel fine") raise Exception("what a pity") except Exception as e: print(e) else: print("the show must go on")

DKAT2023

you write the code error, it should be : raise E("what a pity") instead of raise Exception("what a pity") and except E as e: instead of except Exception as e: , so the corrects are : B and D, not A and D

kstr

You are right lass E(Exception): def __init__(self, message): self.message = message def __str__(self): return "It's nice to see you" try: print("I feel fine") raise E("what a pity") except Exception as e: print(e) else: print("the show must go on") Correct is BD

Dave304409Options: AD

A, D is correct

Dave304409

A, B is correct

DKAT2023Options: AD

A and D are corrects

Dave304409Options: AB

is correct