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

What is the expected behavior of the following code?

    Correct Answer: D

    The code attempts to convert the string '2A' to an integer using the int() function. Since '2A' is not a valid integer, this conversion raises a ValueError. The code has an except block specifically for ValueError, which sets n to 2. Therefore, the correct output is 2.

Discussion
DKAT2023Option: D

D is correct