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 20 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, conditions, and indentation | 1 to 5 | 5 |
| 2 | if-else statements: complete, place, and fix if-else code | 6 to 10 | 5 |
| 3 | if-elif-else statements: build chains in the right order | 11 to 15 | 5 |
| 4 | Predict the output and the error message | 16 to 20 | 5 |
| Total (1 point per item) | 20 | 20 |
Student Information
Items answered: 0 of 20
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 4: the line is not indented. Add spaces at the start so it belongs to the
if. - Item 5: write the whole
ifline yourself.
Too fast!
Free shipping
Welcome back
Time for lunch
Freezing
Task: Complete each if-else program so it matches its comment.
- Item 8: choose which message goes in the else branch.
- Item 9: the line has one mistake. Fix it.
- Item 10: write the whole
ifline yourself.
Not positive
Can vote
Go to school
Game over
Please log in
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 13 and 14: read the rules in the comment carefully. They are not listed in the order the code needs.
- Item 15: write the whole
elifline yourself.
Full
Silver
Afternoon
Task: Trace each small program in your head.
- Items 16 and 17: choose what the program prints.
- Items 18 to 20: each program has a mistake. Choose the error message Python shows.
TerminalProblemsOutput