Exam PCAP All QuestionsBrowse all questions from this exam
Question 82

Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)

A.

B.

C.

D.

    Correct Answer:

    AC

Discussion
DTL001

Correct Answer: AC.

Jnanada

Correct Answer AC B - ValueError will be thrown.

Dav023

B: ----> 6 print(int("")) ValueError: invalid literal for int() with base 10: '' C:----> 6 print(float("1c1")) ValueError: could not convert string to float: '1c1'

dhikra

i think answer BC !!

luckymuki

What is wrong with answer B? Looks like correct option as well

Misco33

You're right, that snippet prints 0 and doesn't raise any exception.

VigneshVj

In B,else block will be executed and it will throw "ValueError: invalid literal for int() with base 10: ''"

seaverick

try: print(0/0) except: print(0/1) else: print(0/2) #try: # print(int("0")) #except NameError: # print("0") #else: # print(int(""))#ValueError: invalid literal for int() with base 10: '' import math try: print(math.sqrt(-1)) except: print(math.sqrt(0)) else: print(math.sqrt(1)) #try: # print(float("1e1")) #except (NameError, SystemError): # print(float("1a1")) #else: # print(float("1c1"))#ValueError: could not convert string to float: '1c1' Ans is A,C

macxsz

Answer: BC

macxsz

sorry, answer is A and C