Instructions
The information on this page is not stored. If you start an assignment, you must finish it. This page does not save your progress.
Quick review
if: maybe run the body
if score >= 70:
print("Pass")
if-else: one of two
if score >= 70:
print("Pass")
else:
print("Try again")
if-elif-else: one of many
if score >= 90:
print("A")
elif score >= 80:
print("B")
else:
print("Keep going")
if,elif, andelseare lowercase, and each line ends with a colon:- The body is indented 4 spaces. Only the indented lines belong to the
if,elif, orelse. elsenever has a condition. It comes last.- In an
if-elif-elsechain, Python checks from top to bottom and runs only the first True branch. - Compare with
==,!=,>,<,>=,<=. A single=stores a value. It does not compare. - Strings need quotes:
light == "yellow". Without quotes, Python thinksyellowis a variable.
Error messages you may see in the terminal
SyntaxError: expected ':'means a colon is missing at the end of anif,elif, orelseline.SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?means you used=where you needed==.IndentationError: expected an indented block after 'if' statement on line 5means the body is not indented.NameError: name 'yellow' is not definedoften means a string is missing its quotes.
How this works
- Enter your first name, last name initial, and class period, then click Start Assignment. Your start time is recorded.
- The assignment opens in a Python editor with four files (tabs). Each orange numbered box or drop down is one practice item. There are 30 items.
- Click ▶ Run on any part to see what Python prints. On Parts 1 to 3, compare it with the expected output. On Part 4, Run shows what each small program prints, so you can check your predictions. Run does not grade you, so check your work carefully.
- When you finish all four tabs, click Submit for Score. Your end time is recorded and your score appears. Answers cannot be changed after submitting.
| Part | Task | Items | Points |
|---|---|---|---|
| 1 | if statements: keywords, operators, colons, conditions, and indentation | 1 to 8 | 8 |
| 2 | if-else statements: complete, place, and fix if-else code | 9 to 15 | 7 |
| 3 | if-elif-else statements: build chains in the right order | 16 to 23 | 8 |
| 4 | Predict the output and the error message | 24 to 30 | 7 |
| Total (1 point per item) | 30 | 30 |
Student Information
Items answered: 0 of 30
Task: Each program has a comment that says what it should do. Fill in every numbered box and drop down so the program works.
- Item 7: the line is not indented. Add spaces at the start so it belongs to the
if. - Item 8: write the whole
ifline yourself.
Hot day!
Perfect score!
Low battery
Access granted
Wear sunscreen
Level up!
Task: Complete each if-else program so it matches its comment.
- Items 11 and 12: choose which message goes in each branch.
- Item 13: the line has one mistake. Fix it.
- Item 15: write the whole
ifline yourself.
Odd
Fail
Good morning
Cold
Locked
Bring an umbrella
Task: Complete each if-elif-else chain. Remember: Python checks from top to bottom and runs only the first True branch, so order matters.
- Items 19 to 21: read the rules in the comment carefully. They are not listed in the order the code needs.
- Item 23: write the whole
elifline yourself.
B
Hot
Slow down
Teen
Task: Trace each small program in your head.
- Items 24 to 27: choose what the program prints.
- Items 28 to 30: each program has a mistake. Choose the error message Python shows.
TerminalProblemsOutput