


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



1 t r y : 2 # Do something 3 e x c e p t : 4 # Do something 5 f i n a l l y : 6 # Do something
(a) no, there is no such thing as finally (b) no, finally cannot be used with except (c) no, finally must come before except (d) yes
Answer: b Explanation: Refer documentation.
(a) no, there is no such thing as else (b) no, else cannot be used with except (c) no, else must come before except (d) yes Answer: d Explanation: Refer documentation.
(a) yes, like except TypeError, SyntaxError [,... ] (b) yes, like except [TypeError, SyntaxError] (c) no (d) none of the mentioned Answer: a Explanation: Each type of exception can be specified directly. There is no need to put it in a list.
(a) when there is no exception (b) when there is an exception (c) only if some condition that has been specified is satisfied (d) always Answer: d Explanation: The finally block is always executed.
(a) we get a True (b) we get a False (c) an TypeError occurs (d) a ValueError occurs Answer: b Explanation: It simply evaluates to False and does not raise any exception. (ASCII value of ‘1’ is compared to 1)