PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 135


What is the expected behavior of the following code?

Show Answer
Correct Answer: D

D

Discussion

3 comments
Sign in to comment
Jos015Option: D
Nov 8, 2023

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

macxszOption: D
May 4, 2022

D. it outputs 2

RizosOption: D
Mar 14, 2023

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

noobplayer
Apr 1, 2023

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