Python Quiz Review Worksheet
Python Programming Quiz Review
Review Sheet
Name:
Date:
You may use your COMPLETED review worksheet during the last 5 minutes of the quiz.
Part 1 – Quick Reference Check
Complete each statement. Use your Python Cheat Sheet if needed.
-
input() always gives back a unless you convert it.
-
- Use to convert input to a whole number.
-
- Use to convert input to a decimal number.
-
= means . == means .
-
- A Boolean value is either or .
-
- A valid variable name cannot contain or begin with a .
-
/ means regular division. // means .
-
+ joins two strings. This is called .
-
* can repeat a string. Example: "Go" * 3 prints .
-
- A single-line comment begins with .
Part 2 – Predict the Output
Write the exact output that appears on screen.
11. What prints?
print("Score:" + str(5 * 2))
Answer:
12. What prints?
print(3 + 4 * 2)
Answer:
13. What prints?
print("Hi" * 2 + "!")
Answer:
14. What prints?
x = 6
print(x >= 6)
Answer:
Part 3 – Conditionals and Boolean Logic
- If
a = 10 and b = 3, decide whether each expression is True or False.
| Expression |
True / False |
| a > 5 and b > 5 |
|
| a > 5 or b > 5 |
|
| not (a < b) |
|
| a == 10 |
|
16. What does this code print?
age = 16
if age < 13:
print("Child")
elif age >= 65:
print("Senior")
else:
print("Adult")
Answer:
17. Why are these TWO separate if statements different from if + elif?
x = 4
if x > 1:
print("A")
if x > 3:
print("B")
Part 4 – Functions: Define, Call, Parameter, Argument
Use this code for Questions 18–21:
def greet(name):
print("Hello " + name)
greet("Maya")
18. What is the function name?
19. What is the parameter?
20. What is the argument?
21. What does the function print?
Part 4 – Functions (continued)
22. Fill in the missing parts so this function works:
def double():
num * 2
answer = double(6)
What value should be stored in answer?
23. Explain the difference between print() and return in a function.
Part 5 – Debugging Repair Shop
Rewrite the corrected line(s) of code for each bug.
24. Fix the variable name.
high score = 98
Fix:
25. Fix the data-type problem.
age = input("Age: ")
print(age + 1)
Fix:
26. Fix the comparison.
score = 90
if score = 90:
print("Great job!")
Fix:
27. Fix the function call.
def cheer():
print("Go!")
cheer
Fix:
28. Fix the missing argument.
def welcome(name):
print("Hello " + name)
welcome()
Fix:
Part 6 – Mini Coding Practice
Watch your indentation and colons!
29. Write an if/else that prints Pass if a score is 70 or higher and Try again otherwise.
30. Write a function named welcome with one parameter named name. It should print Hello plus the name. Then call it using your own name.
Five-Minute Quiz Check: What should I look for?
| If the question is about... |
Check... |
| input() |
Did I remember that input starts as a string? |
| variable names |
No spaces, no hyphens, cannot begin with a number. |
| math |
Order of operations; / vs //. |
| strings |
Strings need quotes; use str() before joining text + number. |
| Boolean/conditions |
= stores; == compares; check and, or, not. |
| if/elif/else |
Only the first true branch in the chain runs. |
| functions |
Was it defined? Was it CALLED with parentheses? |
| parameters |
Did the call provide the needed argument(s)? |
| return |
Does the program need to USE/store the result, not just display it? |
Python Quiz Review Answer Key
Python Programming Quiz Review
Answer Key
Part 1 – Quick Reference Check
-
input() always gives back a string (str) unless you convert it.
-
- Use int() to convert input to a whole number.
-
- Use float() to convert input to a decimal number.
-
= means assignment (stores a value). == means comparison (checks if equal).
-
- A Boolean value is either True or False.
-
- A valid variable name cannot contain spaces (or hyphens) or begin with a number.
-
/ means regular division. // means integer (floor) division (drops the decimal).
-
+ joins two strings. This is called concatenation.
-
* can repeat a string. Example: "Go" * 3 prints GoGoGo.
-
- A single-line comment begins with #.
Part 2 – Predict the Output
11. print("Score:" + str(5 * 2))
Answer: Score:10 (no space after colon)
12. print(3 + 4 * 2)
Answer: 11 (multiplication first)
13. print("Hi" * 2 + "!")
Answer: HiHi!
14. x = 6; print(x >= 6)
Answer: True
Part 3 – Conditionals and Boolean Logic
a = 10 and b = 3
| Expression |
True / False |
| a > 5 and b > 5 |
False (b > 5 is False) |
| a > 5 or b > 5 |
True (a > 5 is True) |
| not (a < b) |
True (not False → True) |
| a == 10 |
True |
-
Answer: Adult (16 is not < 13 and not >= 65, so the else branch runs.)
-
Two separate if statements are both checked independently, so both "A" and "B" print. With if + elif, only the first true branch runs (only "A" would print).
Part 4 – Functions: Define, Call, Parameter, Argument
18. Function name: greet
19. Parameter: name
20. Argument: "Maya"
21. Prints: Hello Maya
22. Completed function & stored value:
def double(num):
return num * 2
Value in answer: 12
print() displays output on the screen, while return sends a value back to where the function was called so it can be stored in a variable or used in another calculation.
Part 5 – Debugging Repair Shop
24. Variable name: high_score = 98
25. Data-type problem: age = int(input("Age: ")) | print(age + 1)
26. Comparison: if score == 90:
27. Function call: cheer()
28. Missing argument: welcome("Maya") (any string works)
Part 6 – Mini Coding Practice (Sample Solutions)
29. if/else for score ≥ 70:
if score >= 70:
print("Pass")
else:
print("Try again")
30. welcome(name) function & call:
def welcome(name):
print("Hello " + name)
welcome("Alex") # student's name