Font size
WorksheetsPython Testing
Total questions: 10
Worksheet time: 5mins
Function definitions in Python start with what keyword?
def
fun
function
define
A function parameter is a kind of variable accessible...
Which two statements are true?
The return keyword forces a function to restart its execution
The return keyword may cause the function to return a value
The return keyword forces the function's execution to terminate
The return keyword can only appear once inside a function
What is the output of the following Python code?
tup = (1, ) + (1, )
tup = tup + tup
print(len(tup))
2
4
0
the snippet causes an error
What is the output of the following code if the user enters "kangaroo" as their first prompt and 0 as their second?
Error.Error.Error
4.0
Do not divide by Zero!
Wrong value.
What is the expected behaviour of the following snippet if the user enters 0?
value = input("Enter a value: ")
print(10 / value)
The program will raise a ValueError exception
The program will raise the ZeroDivisionError exception
The program will raise the TypeError exception
The program will output 0 to the console
What is the output of the following Python code?
list = [1, 2, 3, 4]
print(list[4])
4
1
the snippet causes an IndexError
None
What is the expected behaviour of the following snippet if the user enters a string?
value = input("Enter a value: ")
print(10 / int(value))
The program will raise a ValueError exception
The program will raise the ZeroDivisionError exception
The program will raise the TypeError exception
The program will output 0 to the console
What is the expected behaviour of the following snippet if the user enters a negative number?
value = input("Enter a value: ")
print(10 / int(value))
The program will raise a ValueError exception
The program will output a negative number to the console
The program will raise the TypeError exception
The program will output 0 to the console
What is the expected behaviour of the following snippet if the user enters a string?
value = input("Enter a value: ")
print(value.isnumeric())
The program will raise a ValueError exception
The program will output False to the console
The program will raise the TypeError exception
The program will output True to the console
