Below are optional practice problems for Quiz 0. These problems are intentionally a bit more challenging than what you will see on the quiz.
Solutions for each problem can be found at the bottom of this page.
Questions
Booleans and Conditionals
What values of x and y would cuase the following expression to evaluate to
True
?x % 3 == 2 and y < 10 and x + y == 15 and y % 2 != 0
- Write the boolean value each expression evaluates to:
(8 * 3) == (50 % 6 * 12)
not False and True == True
not False or True and False
true and 7 < 3 * 4 / 6
not 4 < 10 or False != True
With the following code snippet, what output will appear on the screen when each of the following values is used for x and y?
- When x = 3, y = 5?
- When x = 5, y = 3?
- When x = -5, y = 1?
- When x = 13, y = 8?
- When x = 4, y = 3?
Diagramming and Functions
- Given the code listing below, produce a memory diagram including the stack, heap, and output.
Solutions
Booleans and Conditionals
- x: 8, y: 7
True
True
True
False
"True"
"17"
"2"
"-2"
"3"
"1"