Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)
A.
B.
C.
D.
Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)
A.
B.
C.
D.
AC
Correct Answer: AC.
Correct Answer AC B - ValueError will be thrown.
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'
i think answer BC !!
What is wrong with answer B? Looks like correct option as well
You're right, that snippet prints 0 and doesn't raise any exception.
In B,else block will be executed and it will throw "ValueError: invalid literal for int() with base 10: ''"
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
Answer: BC
sorry, answer is A and C