Exam PCAP All QuestionsBrowse all questions from this exam
Question 135

What is the expected behavior of the following code?

    Correct Answer: D

    D

Discussion
Jos015Option: D

ValueError s = '2A' try: n = int(s) except ValueError: n=2 except ArithmeticError: n=1 except: n=0 print (n)

RizosOption: D

Can anyone explain what is happening here? why is the answer 2?

noobplayer

because it causes ValueError. you cannot cast the input to int because there is a character within

macxszOption: D

D. it outputs 2