Python Basics Quiz Examples
Questions exemplary of the type to be expected during our in-class quiz
Select the syntax for declaring a variable in Python
var x = 5;
val x = 5
int x = 5
x: int = 5
x = 5
x = 5;
global x = 5
What is the result of this expression? (in Python 3 of course!)
(1/3)**3 == 1/(3**3)
Guaranteed to be True
Maybe True, maybe False; It depends on limited precision arithmetic
Since Python is dynamically typed (variables, arguments, etc don't have declared types), there is no way for the programmer to determine the type of a value.
Given that "x = list()", what is the result of this expression?
0 if not x else x[-1]
Index out of bounds exception raised
We can't tell knowing only what we know
What is the result of: range(1, 4)
What is the name for this construct:
[x + 1 for x in range(4)]
Which is NOT a way to learn more about the contents of a variable and what you can do with it?
Tab after the dot syntax to see available methods
The help function with the variable name
The help function with the variable name "dot" and the name of a method
The type function
Typing the variable and hitting enter to see the printed representation of the contents
Randomly trying to do things with it (like division) and seeing the results or exception messages
Allowing frustration to sap your will to continue (ok, I couldn't come up with a good one)
The section titled "Tuples, a key part of Python" is mostly...
An informative and qualitative description
To excel in the quiz, a good strategy is to
Make up a few quiz questions of my own for each section, including dictionaries, sets, functions, and equality
Type up a fact sheet with your favorite Python knowledge nuggets
Scroll down the python notebook, hiding the results with a paper, and trying to guess the result of the input cells
This form was created inside of Colorado State University.
Terms of Service