← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 8 · Midterm study guide

Midterm Exam — Study Guide

Introduction to Computer Science Free sample edition

Coverage — what the midterm covers

The midterm is cumulative over Weeks 1–7, which is Objectives 1 to 5 as taught in those weeks. It opens in the Week 8 module and closes at the due time your instructor sets. There is no time limit, and you get one attempt. The questions appear one at a time, and you cannot go back once you move on.

Format: 25 questions, and every question counts the same. Of the 25, 19 ask you to pick one option, 3 ask you to judge a statement as true or false, and 3 ask you to pick every option that applies. Every program a question asks about is printed in the question, and any output it refers to is written out in words or text. The midterm is closed to AI, so the only runner you have is the one in your head: predict, then check your prediction against the rules.

What is in scope, with the number of midterm questions on each course objective:

Midterm coverage by course objective: the weeks the drawn questions come from, the main skills, and the number of questions out of 25
Course objective Weeks the questions come from Main skills Questions
1. Programs, tracing, and error messages 1, 2, and 3 Predict what a line prints, check a claim about a program by running it, and read an error from its last line to tell a SyntaxError from a runtime exception 5
2. Values, types, expressions, and strings 2, 3, 4, and 6 Operator precedence, the types int, float, str, and bool, round-half-to-even, converting a typed string, indexing and the IndexError, comparing values across types, and walking a string one character at a time 8
3. Booleans and conditionals 4 Truth tables, the priority not, then and, then or, and the rule that only the first true branch of an if statement runs 4
4. Loops 5, 6, and 7 The while loop and the infinite loop, range with a start, a stop, and a step, the exclusive stop, and counting what a loop prints 5
5. Functions and scope 7 Parameters and arguments, argument order, return values, and the None a printing function hands back 3

By week, the questions come out as 2 from Week 1, 6 from Week 2, 3 from Week 3, 5 from Week 4, 1 from Week 5, 4 from Week 6, and 4 from Week 7. Week 2 carries the most questions, 6 of the 25, so put the most review time on variables, types, and expressions. Week 4 comes next with 5. By objective, values and types carry 8 questions, the largest share. By difficulty, 10 questions are easy, 12 are medium, and 3 are hard.

Week 8's classic-bug checklist is not scored on its own. It is still the best way to review, because many midterm questions turn on one of its six slips.

Topic-by-topic review

Each topic gives the key idea in plain words, the course's own definitions, a course example from that week's pinned programs, and the mistakes students make most often with the cure for each. The deeper review for every topic is that week's chapter, lecture page, slide deck, and readings. Every output below is what Python printed when the program ran.

Week 1 — Introduction to computing and computational thinking

  • Key idea: the computer does exactly what you wrote, not what you meant. You predict what a program prints, run it, and read any error from its last line.
  • Algorithm and program: an algorithm is a finite, unambiguous list of steps that solves a whole class of problems. A program is an algorithm written in a language a computer can run; the computer carries out its instructions literally and in order.
  • Working habits: decomposition splits one large task into smaller steps you can check one at a time. The edit, run, read the output, fix loop is the working cycle of programming. To trace is to read a program one line at a time and write down what each step does, so you can predict its output before you run it.
  • print and its arguments: print displays its arguments as one line of output, with one space between each pair, and then ends the line. An argument is a value placed inside the parentheses of a function call. A string is a piece of text inside quotation marks, kept exactly as typed.
  • Operator precedence: the rule that decides which operator Python works out first, such as multiplication before addition, with parentheses always going first.
  • Errors: an error message is read from the bottom up, because its last line names the error type. A SyntaxError means the parser refused the program's text, so no line ran at all. A NameError means a running program used a name Python does not know, such as Print with a capital P. Python is case-sensitive, so print and Print are two different names.
  • Course example: print(2 + 3 * 4) prints 14, because 3 × 4 = 12 comes first and 2 + 12 = 14. print((2 + 3) * 4) prints 20. print("2" + "3") prints 23, while print(2 + 3) prints 5.
  • Predictable mistakes → cures: (1) "the computer understands what I meant." Cure: it runs what you wrote, character by character. (2) ""2" + "3" adds the numbers." Cure: quotation marks make text, and + joins two strings end to end. (3) "2 + 3 * 4 is 20." Cure: * binds tighter than +. (4) "a red error means I failed." Cure: it is a map to the bug; read the last line and name the type.

Week 2 — Variables, data types, and expressions

  • Key idea: a name holds a value, every value has a type, and the type decides what prints.
  • Assignment: a variable is a name that holds a value so a program can use it later. Assignment puts the value on the right of = into the name on the left; read = as "gets." Reassignment replaces the old value and leaves every other name exactly as it was.
  • The four core types: int is Python's type for whole numbers, such as 255 or −4. float is the type for numbers written with a decimal, such as 8.5 or 5.0. str is the type for text; "255" is a str even though every character is a digit. bool holds the two truth values, True and False. type() reports a value's type.
  • The operators: the exponent operator ** is worked out before any other arithmetic operator. True division with / always gives a float, even when the numbers divide evenly. Floor division with // rounds the quotient down toward negative infinity. The remainder operator % gives what is left over after floor division.
  • Conversion: type conversion turns one type into another with int(), float(), or str(). Truncation cuts off the decimal part without rounding, the way int(3.9) gives 3. A TypeError is raised when an operation meets a value of the wrong type, such as adding a string to a number. Round-half-to-even is the rule round() follows for an exact half: round(2.5) is 2 and round(3.5) is 4.
  • Course example: the reading log sets goal = 300 and pages_read = 45, so pages_left is 300 − 45 = 255. Then pages_left / 30 prints 8.5, pages_left // 30 prints 8, and pages_left % 30 prints 15. As a check, 8 × 30 = 240 and 240 + 15 = 255.
  • Predictable mistakes → cures: (1) "10 / 2 is 5." Cure: / always gives a float, so it prints 5.0. (2) "// rounds." Cure: it floors, so -7 // 2 is −4. (3) "= and == are the same." Cure: = gives a name a value; == asks a question. (4) ""5" + 3 is 8." Cure: it raises TypeError; convert first with int("5"). (5) "Total and total are one name." Cure: Python is case-sensitive.

Week 3 — Input, output, and strings

  • Key idea: text is a row of characters you can count, pick from, and cut, and anything typed in arrives as text.
  • input(): input() shows a prompt, waits for the user to type a line, and hands back exactly what was typed as a string. Convert it with int() before any arithmetic.
  • f-strings: an f-string has the letter f right before its opening quote, and every pair of curly braces holds a name or an expression whose value Python fills in. Concatenation joins two strings with +, and it works only when both sides are strings.
  • Indexing: an index picks one character, counting from 0 at the left (zero-based indexing). A negative index counts back from the end, so -1 is the last character. len() counts every character, spaces and punctuation included. An IndexError is raised when an index lands where no character sits.
  • Slicing: a slice s[start:stop] keeps the characters from index start up to, but not including, index stop. It is half-open, so s[1:4] holds three characters. A slice is forgiving: a stop past the end stops at the end instead of raising an error.
  • Course example: with book = "the river book", book[0] is t, book[-1] is k, and book[4:9] is river, which is 9 − 4 = 5 characters. len(book) is 14, so book[14] raises IndexError, while book[4:99] prints river book.
  • Predictable mistakes → cures: (1) "input() gives a number when the user types digits." Cure: it always gives a string. (2) "s[1:4] includes index 4." Cure: the stop is left out. (3) "the last character of "cat" is s[3]." Cure: it is s[2], or s[-1]. (4) "a string without the f prefix fills in {name}." Cure: only an f-string fills in braces.

Week 4 — Booleans and conditionals

  • Key idea: a yes-or-no question picks which code runs, and only the first true branch runs.
  • Comparisons: a Boolean expression works out to True or False. The six comparison operators are ==, !=, <, >, <=, and >=. The equality operator == asks whether two values are equal, unlike =, which gives a name a value.
  • Logical operators: and gives True only when both sides are True; or gives True when at least one side is; not flips one value. A truth table lists every combination of inputs, in the pinned row order True True, True False, False True, False False. Python works out not, then and, then or.
  • if statements: a condition is the Boolean expression after if or elif. A branch is one alternative block; Python runs at most one branch each time. elif is checked only when every test above it was False, and else runs only when they all were. A logic error lets the program run with no error message but print the wrong thing.
  • Truthy and falsy: the empty string and the number 0 are falsy; any string with at least one character is truthy, so bool("0") is True.
  • Course example: print(True or False and False) prints True, because False and False is False first, and then True or False is True. The pinned chain with x = 7 tests x > 10 (False) and then x > 5 (True), so it prints medium. With total = 95, a chain that tests 60 or more first prints D or better; testing 90 or more first prints A.
  • Predictable mistakes → cures: (1) "= and == are interchangeable." Cure: if x = 5: is a SyntaxError. (2) "and and or are read left to right." Cure: Python works out not, then and, then or, in that order. (3) "the order of elif tests does not matter." Cure: put the strictest test first. (4) "not (3 > 2) is True." Cure: the parentheses go first, so it is not True, which is False. (5) "0 and the empty string are not Booleans." Cure: both are falsy.

Week 5 — Loops I: the while loop

  • Key idea: a while loop asks its question at the top of every pass, never in the middle of one.
  • Definitions: a while loop repeats its indented body for as long as its condition is True. The loop condition is tested before each pass, and the loop body runs from top to bottom on every pass. A pass is one complete run through the body.
  • Counters and accumulators: a counter starts before the loop and goes up by one each pass. An accumulator starts at a value such as 0 and collects a running total. count += 1 is shorthand for count = count + 1.
  • Off-by-one and infinite loops: an off-by-one error runs one pass too many or too few, most often because a condition uses less than where it needed less than or equal to, or the reverse. An infinite loop never stops because nothing in its body moves it toward the stop; Ctrl+C or a browser runner's Stop button ends it. break ends the loop at once, and while True is used on purpose when a break decides the stop.
  • Course example: the reading log starts at 45 pages, aims for 300, and adds 30 a day. It prints 9 and then 315. After 8 passes the total is 45 + 8 × 30 = 285, which is still below 300, so a ninth pass runs: 285 + 30 = 315, which is 15 pages past the goal. The pinned counter count = 1 with the test "count is at most 5" ends at 6, one past the last value that passed.
  • Predictable mistakes → cures: (1) "the loop stops the moment the condition turns False mid-body." Cure: it finishes the pass and tests at the top. (2) "less than and less than or equal to give the same passes." Cure: they differ by one pass. (3) "a stuck loop means the computer is broken." Cure: look for the missing update line. (4) "the counter of a loop that runs while it is at most 5 ends at 5." Cure: it ends at 6. (5) "while True is always a bug." Cure: with a break inside, it is a deliberate tool.

Week 6 — Loops II: for, range, and nested loops

  • Key idea: a for loop hands you one item per pass, and a range never produces its stop.
  • Definitions: a for loop runs its body once for each item of a sequence. The loop variable is set to the next item at the start of every pass, so it needs no update line. range() produces whole numbers from a start (0 when none is given) up to but not including a stop, moving by a step (1 when none is given). The exclusive stop means range(1, 5) gives 1, 2, 3, and 4.
  • Printing on one line: end= replaces the line break print normally adds, so end=" " leaves a space and end="" leaves nothing. A bare print() then ends the row.
  • Nested loops: a nested loop sits inside another loop's body. The inner loop runs all of its passes before the outer loop moves on, so the line count is outer passes × inner passes.
  • Course example: list(range(0, 10, 3)) is [0, 3, 6, 9], and len(range(1, 10, 3)) is 3, because the range holds 1, 4, and 7. The pinned nested loop over range(2) and range(3) prints six lines, 2 × 3 = 6. The reading log's loop over range(1, 8) runs 8 − 1 = 7 days and ends at 45 + 7 × 30 = 255.
  • Predictable mistakes → cures: (1) "range(1, 5) gives 1 to 5." Cure: the stop is left out, so use range(1, 6). (2) "range(5) starts at 1." Cure: it starts at 0. (3) "the inner loop runs once, then the outer continues." Cure: it runs completely on every outer pass. (4) "range(0, 10, 2) includes 10." Cure: 10 is the stop. (5) summing 1 to n with range(1, n). Cure: range(1, n + 1).

Week 7 — Functions

  • Key idea: print shows a value to you; return hands it back to the code.
  • Definitions: a function is a named block of code that runs only when a line calls it. def starts a definition, so defining a function prints nothing. A function call runs the body once. A parameter is a name inside the parentheses of the def line; the argument in the matching position of the call fills it, so argument order matters.
  • return: return ends a call and hands the value after it back to the line that made the call. The return value is the value of the call expression itself. None is Python's value for no value at all; a function with no return line hands back None.
  • Scope: a local variable is created inside a function, including each parameter, and is gone once the call ends. A global variable is created at the top level; code inside a function can read it, but a plain assignment inside the function makes a separate local name. Scope is the part of a program where a name can be used, and a frame is the box of local names a call sets up.
  • Course example: pages_left(300, 45) returns 300 − 45 = 255, and pages_left(200, 45) // 30 is 5, because 200 − 45 = 155 and 5 × 30 = 150 fits in 155. The pinned show(4) prints 8 inside the function and returns nothing, so print(show(4)) prints 8 and then None. The pinned n = 5 program, whose function sets a local n = 99, still prints 5.
  • Predictable mistakes → cures: (1) "print and return do the same thing." Cure: only return hands a value back. (2) "defining a function runs it." Cure: only a call runs it. (3) "parameters and arguments are the same word." Cure: parameters sit in the def; arguments sit in the call. (4) "a variable set inside a function changes the outer one." Cure: a plain assignment inside makes a new local. (5) "argument order does not matter." Cure: values bind by position.

Week 8's new habit (not scored on its own)

The classic-bug checklist is six slips you read for before you run any program. The first three are = written where == belongs, a range or slice whose stop is left out, and / giving a float. The last three are two strings joined by + instead of added, a function with no return handing back None, and a while loop whose body never moves its condition toward False. Predict, then run is the habit underneath it: write down what a program prints before you run it, and let the gap show you which rule needs another look.

Representative practice

These are fresh variants, not the midterm's questions. Every program below is illustrative, and every output block is exactly what Python 3 printed when the program ran. Cover each output, predict it, and then compare.

Worked example — an order of seeds and a laundry room (Week 1)

An illustrative seed order adds 4 loose packets to 5 bundles of 2. Predict all four lines.

print(4 + 5 * 2)
print((4 + 5) * 2)
print("4" + "5")
print(4 + 5)

Output

14
18
45
9

The first line works out 5 × 2 = 10 first and then 4 + 10 = 14. The parentheses in the second line go first: 4 + 5 = 9 and 9 × 2 = 18. The third line joins two strings into 45; the fourth adds two numbers to make 9.

Now an illustrative campus laundry-room display, with a name that was never assigned.

print("Washers free: 3")
print(dryers_free)

Output

Washers free: 3
NameError

The first line ran, so the error happened while the program was running: a NameError, a runtime exception. Drop the closing parenthesis from line 2 instead, and nothing prints at all; the last line names SyntaxError, because the parser refused the text before any line ran.

Why it matters: * binds tighter than +, and the last line of an error tells you which kind of mistake you are looking at.

Worked example — seedlings on trays (Week 2)

An illustrative garden has 45 seedlings and fits 10 on a tray.

seedlings = 45
per_tray = 10
print(seedlings / per_tray)
print(seedlings // per_tray)
print(seedlings % per_tray)
print(type(seedlings / per_tray))

Output

4.5
4
5
<class 'float'>

In words: true division gives 4.5 trays, a float. Floor division says 4 trays fill completely, and the remainder says 5 seedlings are left over; as a check, 4 × 10 = 40 and 40 + 5 = 45.

Five more lines, one rule each.

print(2 * 4 ** 2)
print(round(4.5), round(5.5))
print(int(9.8))
print(int("12") + 3)
print("12" + "3")

Output

32
4 6
9
15
123

The exponent goes first, 4 × 4 = 16, then 2 × 16 = 32. Each half rounds to its even neighbour, so 4.5 becomes 4 and 5.5 becomes 6. int(9.8) truncates to 9 rather than rounding. Converting "12" first gives 12 + 3 = 15, while two strings join to 123. Writing print("12" + 3) instead raises TypeError.

Why it matters: say the type of each value before you say what prints.

Worked example — a plant label and a typed row count (Week 3)

An illustrative garden app stores the label "sunflower", which has nine characters at indexes 0 to 8.

label = "sunflower"
print(label[0])
print(label[-1])
print(label[3:6])
print(len(label))
print(label[3:50])
print(label[9])

Output

s
r
flo
9
flower
IndexError

The slice [3:6] keeps indexes 3, 4, and 5, which is 6 − 3 = 3 characters. Index 9 is one past the last index, 9 − 1 = 8, so the strict index raises IndexError, while the slice to 50 stops quietly at the end.

Next, the user types 12 for the number of rows, pinned as the literal "12".

label = "sunflower"
typed = "12"
print(typed * 2)
rows = int(typed)
print(rows * 2)
print(f"{rows} rows of {label}s")

Output

1212
24
12 rows of sunflowers

A string times 2 repeats the text. After int(), the same symbol multiplies: 12 × 2 = 24. The f-string fills in both names.

Why it matters: typed input is text until you convert it, and a slice stops before its stop.

Worked example — a parking garage's rates (Week 4)

An illustrative garage charges by how long a car stays.

hours = 3
if hours > 4:
    print("Day rate")
elif hours > 2:
    print("Half-day rate")
else:
    print("Hourly rate")

Output

Half-day rate

The first test asks whether 3 is greater than 4, which is False. The second asks whether 3 is greater than 2, which is True, so that branch runs and Python skips the rest.

Swap the two tests and set hours = 6. The program prints Half-day rate again, with no error, because 6 passes the looser test first. That is a logic error; putting the stricter test first makes it print Day rate.

Two Boolean lines and a truth table:

print(False or True and False)
print(not (2 > 5))

Output

False
True

True and False is worked out first and gives False; then False or False is False. In the second line the parentheses go first, so 2 > 5 is False and not False is True.

The expression not a and b on the four rows of a truth table, in the pinned row order, as printed by a run
a b not a and b
True True False
True False False
False True True
False False False

not is applied to a first, so the expression is True only on the row where a is False and b is True.

Why it matters: not, then and, then or, and only the first true branch runs.

Worked example — a rain barrel and a stopping rule (Week 5)

An illustrative rain barrel holds 10 liters and gains 15 liters per storm until it reaches 50.

liters = 10
fills = 0
while liters < 50:
    liters = liters + 15
    fills = fills + 1
print(fills)
print(liters)

Output

3
55

The test happens only at the top of each pass. After two storms the barrel holds 10 + 2 × 15 = 40, which is still below 50, so a third pass runs: 40 + 15 = 55, which is 55 − 50 = 5 liters past the target.

A counter's final value:

k = 2
while k <= 7:
    k = k + 1
print(k)

Output

8

The last value that passed the test was 7, so the counter ends one past it, at 8. Delete the line k = k + 1 and print k inside the body instead, and the run prints 2 over and over without stopping until you press Ctrl+C or the Stop button: an infinite loop.

A deliberate while True with break, looking for the first number of full crates of 7 that holds more than 60 jars:

n = 1
while True:
    if n * 7 > 60:
        print(n)
        break
    n = n + 1

Output

9

8 × 7 = 56 is not above 60, and 9 × 7 = 63 is, so the loop prints 9 and the break ends it.

Why it matters: every while loop needs a line that moves it toward its stop, and the counter ends one past the last value that passed.

Worked example — a bookshelf, two ranges, and a running total (Week 6)

for letter in "shelf":
    print(letter)

Output

s
h
e
l
f

A five-character string gives five passes and five lines.

print(list(range(5, 12, 3)))
print(len(range(0, 20, 5)))

Output

[5, 8, 11]
4

The first range starts at 5 and steps by 3; 14 would pass the stop of 12, so it is never produced. The second holds 0, 5, 10, and 15, four values, and never 20.

An illustrative bookshelf has 3 shelves of 5 slots:

for shelf in range(3):
    for slot in range(5):
        print(shelf, slot)

Output

0 0
0 1
0 2
0 3
0 4
1 0
1 1
1 2
1 3
1 4
2 0
2 1
2 2
2 3
2 4

The inner loop finishes all 5 passes before the outer loop moves on, so the line count is 3 × 5 = 15.

To add 1 through 6, the loop needs range(1, 7), which gives 1 + 2 + 3 + 4 + 5 + 6 = 21. Writing range(1, 6) instead prints 15, because it stops before 6: an off-by-one.

Why it matters: count a range's values before you count anything else.

Worked example — concert seats and a party mode (Week 7)

An illustrative concert hall has 120 seats.

def seats_left(capacity, sold):
    return capacity - sold

print(seats_left(120, 85))
print(seats_left(85, 120))
print(seats_left(120, 85) // 10)

Output

35
-35
3

The first call binds capacity to 120 and sold to 85, so it returns 120 − 85 = 35. Swapping the arguments binds them the other way, 85 − 120 = −35. The returned 35 can be used in an expression: 35 // 10 is 3 full rows of 10.

A function that prints instead of returning:

def display(n):
    print(n * 3)

print(display(7))

Output

21
None

The body prints 7 × 3 = 21. The call hands back None, because there is no return line, and the outer print shows it.

A local name inside a function:

mode = "quiet"

def party():
    mode = "loud"
    print("inside", mode)

party()
print("outside", mode)

Output

inside loud
outside quiet

The assignment inside party made a new local mode, which vanished when the call ended, so the global still holds "quiet".

Why it matters: print shows a value to you; return hands it back to the code.

Worked example — the checklist on three programs (Week 8)

Read each program for the six slips, predict, and then compare.

for row in range(1, 4):
    print(row)

Output

1
2
3

If the goal was rows 1 to 4, the slip is the exclusive stop: the range needs range(1, 5).

print("7" + "8")

Output

78

Two strings join to 78 instead of adding to 15.

def half(n):
    print(n / 2)

x = half(9)
print(x)

Output

4.5
None

Two slips sit here. True division gives the float 4.5, and the function prints instead of returning, so x holds None. With return n / 2 in the body, the same program prints 4.5 once.

Why it matters: most errors are one wrong character, and the checklist finds them before you run.

Self-check questions

Try each one, then read the check and the one-line why.

  1. What does print(9 // 4, 9 % 4) show? Check: 2 1. Why: 4 fits into 9 twice, 2 × 4 = 8, and 9 − 8 = 1 is left over.
  2. What does print(15 / 3) show? Check: 5.0. Why: / always gives a float, even when the division comes out even.
  3. What does print("bread"[1:4]) show? Check: rea. Why: the slice keeps indexes 1, 2, and 3 and leaves out the stop.
  4. What does print(True and not False) show? Check: True. Why: not False is True first, and True and True is True.
  5. A counter starts with c = 0, and a while loop adds 1 to it while it is less than 3. What does print(c) show after the loop? Check: 3. Why: the last value that passed the test was 2, so c ends one past it.
  6. How many values does range(3, 15, 4) hold? Check: 3, namely 3, 7, and 11. Why: 15 is the stop and is never produced.
  7. A function returns its argument plus 2. What does print(add_two(5) * 2) show? Check: 14. Why: the call returns 5 + 2 = 7, and 7 × 2 = 14.
  8. Which error type does print("bus " + 7) raise? Check: TypeError. Why: + cannot join a string to a number.

Check yourself — choose one. Write two or three sentences to a friend.

  • (a) Explain why the rain barrel ends at 55 liters instead of stopping at 50.
  • (b) Explain why print(display(7)) shows two lines when the function body has only one print.

Either one rehearses an explain-why skill the midterm checks.

Watch before the exam

These videos come from the course's vetted Week 8 pool, and every one has captions. Use them to review and to connect weeks, not to learn anything new.

Study plan

A short countdown. Count back from the day you plan to sit the midterm.

  • Two weeks out: as you finish Week 6, start a one-page list of the course's swapped pairs: = and ==, / and //, int and float, str and int, while and for, and range(n) and range(1, n + 1). Add parameter and argument, return and print, and local and global when Week 7 arrives.
  • One week out: as you finish Week 7, reread the topic reviews above for Weeks 2 and 4, the two weeks that carry the most midterm questions.
  • At the start of Week 8: take the practice exam once, cold and closed-note. Note which objectives cost you the most. Its mix leans away from Week 2, so check variables, types, and expressions on your own as well.
  • Three or four days before you sit it: reread the topic reviews for your two weakest objectives, and redo the matching worked examples above with each output covered.
  • Two days before: run the paired exam-prep tutorial (the copy-and-paste chatbot tutor, or its no-AI route) for active recall. Tell it which areas the practice exam exposed.
  • The day before: retake the practice exam, explain every miss out loud, and work the self-check questions above.
  • Right before: say the six classic slips aloud, then the priority not, then and, then or, in that order. Skim the "predictable mistakes → cures" lines for all seven weeks, and then stop studying.

This guide is for review. The exam-prep tutorial and the practice exam are where you rehearse. Pulling ideas back out of memory, not rereading, is what makes them stick.

Exam format

Every one of the 25 questions counts the same, and the midterm checks your own reading of code without AI. The questions come one at a time, and there is no going back, so settle each one before you move on.

Test-taking strategies for this material:

  • Name the type first. Before you say what a line prints, say whether each value is an int, a float, a str, or a bool.
  • Write the trace on scratch paper. For a loop, list each pass with the value of the counter at the top of the pass.
  • Count a range before you use it. Write out its values, and remember the stop never appears.
  • Find the first true branch. Test each condition in order, and stop at the first one that comes out True.
  • Ask what the call hands back. If the function has no return line, the call is None, whatever it printed.
  • Read the last line of any error. Name the type, then ask whether the parser refused the text or the program ran and raised.
  • For a "pick every option that applies" question, judge each statement on its own, as if it were a true-or-false question.

Built with The Course Maker · samples.thecoursemaker.com