NEW
Font size
WorksheetsExceptions and Definitions
Total questions: 12
Worksheet time: 6mins
How many except statements can a try-except statement have?
None
One
Two
Multiple
When is the finally block executed?
when an exception occurs
when no exception occurs
never
always
When will the else part of try-except-else be executed?
always
when an exception occurs
when no exception occurs
never
Can one except block handle multiple exceptions?
Yes
No
May be
Insufficient information
What is the output of the attached python code?
100
0
Zero Division Error Occurred
Another error will occur, program will "crash"
What is the output of the attached python code?
Value error
Finally done
Type error
Finally done
Type error
Value error
Finally done
What term is used to describe data passed into a definition?
Variable
Loop
Constant
Parameter
How do you correctly call this function definition?
def(1)
x=square( )
square(4)
x=square(5)
What is a variable defined inside a definition referred to as?
A static variable
A global variable
A local variable
An automatic variable
Which of the following statements is NOT true?
Definitions are examples of reusable code
Definitions are always appropriate in programs
Using definitions make it easier to "deconstruct" a problem into smaller pieces
Definitions can make programs easier to read and understand
What would the output be for the following program if the user enters 4 and 6?
10
14
16
error
What will be printed?
nothing
5
6
an error message
