Code Interpretation Quiz
Test your ability to analyze and understand various code snippets. Please answer all questions carefully.
Full Name
*
First Name
Last Name
Email Address
*
example@example.com
Which of the following is the output of the following Python code? x = 3 print(x * 2 + 1)
*
7
9
5
6
Select all valid variable names in Python.
*
_myVar
2ndVar
var_2
my-var
Other
Match the code snippet to its output.
*
Rows
Output
print(list(range(1,4)))
[1, 2, 3]
Error
[3, 2, 1]
[1, 2, 3, 4]
print([1,2,3][::-1])
[1, 2, 3]
Error
[3, 2, 1]
[1, 2, 3, 4]
print(1/0)
[1, 2, 3]
Error
[3, 2, 1]
[1, 2, 3, 4]
Enter the output that will be printed by the code above:
Output
Which line contains an error in the following code? 1. x = 5 2. y = '3' 3. z = x + y 4. print(z)
*
Line 1
Line 2
Line 3
Line 4
Rate your confidence in interpreting code written in Python.
*
Not confident
1
2
3
4
Very confident
5
1 is Not confident, 5 is Very confident
What is the output of the following code? my_list = [0, 1, 2] print(my_list[-1])
*
0
1
2
Error
Choose the correct description for the following code: def greet(name): print("Hello, " + name) greet("Sam")
*
Prints Hello, Sam
Prints name, Hello
Syntax error
Prints greet(name)
Explain in a few words what the following code does: nums = [1, 2, 3, 4] for n in nums: if n % 2 == 0: print(n)
*
Which of the following statements about Python lists is TRUE?
*
Lists can contain elements of different types.
Lists are immutable.
Lists cannot be nested.
Lists have a fixed size.
Submit Quiz
Should be Empty: