How to Study for Intro to Computer Science (CS1)
How to study for intro to computer science: trace code by hand, learn the Python traps exams test, drill exceptions and Big-O, and practice coding every week.
Intro to computer science is two courses sharing one syllabus. The first is a skill: writing programs that work. You can only build it by writing code, running it and fixing it. The second is a body of knowledge: what a given line does, which exception it raises, what a function returns, how fast an algorithm grows. That half is tested on paper, often without a computer, and it responds to the same study methods as any other course.
Most students only do the first half and are surprised when the exam asks them to predict output from a snippet they have never seen. Here is how to cover both.
How CS1 is tested
Typical exam questions fall into four groups:
- Predict the output. Here is a loop, what does it print? These are the most common.
- Find the error. Which line raises an exception, and which exception is it? Or: this runs but gives the wrong answer, why?
- Vocabulary. Parameter versus argument, mutable versus immutable, base case, method resolution order.
- Write a short function. Usually on paper, so syntax mistakes the editor would catch now cost points.
The first three are concept work. The fourth needs real practice in an editor, plus the habit of writing code by hand at least occasionally before the exam.
Trace before you run
The single most useful skill in CS1 is tracing: walking through code line by line and tracking every variable's value on paper. Students who run code to see what it does learn less than students who predict first and then run it to check. The prediction is what builds the mental model, which is the generation effect at work: producing an answer yourself makes it stick better than reading one.
A simple routine for every example in your textbook or lecture:
- Cover the output.
- Write down what you think it prints, with the value of each variable after each line.
- Run it.
- If you were wrong, find the exact line where your trace and Python disagreed.
Step 4 is where the learning happens. A wrong prediction you track down teaches more than ten right ones.
Learn the traps on purpose
CS1 exams return to the same small set of beginner traps. Encodr's Intro to Computer Science course seeds them across units deliberately, and it is worth knowing them by name. Each of these was run in Python 3:
```python print(7 / 2, 7 // 2, -7 // 2, -7 % 2) # 3.5 3 -4 1 print(0.1 + 0.2 == 0.3) # False print(round(2.5), int(-5.9)) # 2 -5
a = [1, 2, 3] b = a b.append(4) print(a) # [1, 2, 3, 4]
def add_item(item, lst=[]): lst.append(item) return lst
print(add_item("x")) # ['x'] print(add_item("y")) # ['x', 'y']
names = ["Ana", "Bo"] names = names.append("Cy") print(names) # None ```
What each one tests:
//floors toward negative infinity, so-7 // 2is -4, not -3.%with a positive divisor is never negative.- Floats are stored in binary, so
0.1 + 0.2is not exactly 0.3. Never compare float results with==. roundsends ties to the even neighbour;inttruncates toward zero instead of rounding.b = adoesn't copy a list. Both names point at one list, so changing it throughbchangesa.- A default list is created once, when
defruns, and is shared by every call that omits the argument. The standard fix is a default ofNone. appendchanges the list in place and returnsNone, so assigning its result throws the list away.
Make a one-line card or note for each trap and review them until you spot them on sight.
Exceptions are a vocabulary list
"Which exception does this raise?" questions are pure recall once you know the categories, and they are easy points:
| Exception | Typical cause |
|---|---|
| TypeError | Wrong type for the operation, like "5" + 5 |
| ValueError | Right type, unsuitable value, like int("3.5") |
| IndexError | Sequence position out of range (slices never raise it) |
| KeyError | Missing dictionary key |
| NameError | A name that was never assigned |
| AttributeError | An object without that attribute or method |
| ZeroDivisionError | Dividing or taking modulo by zero |
Drill these with retrieval, not rereading. Cover the right column and name the cause, then cover the left column and name the exception. The testing effect explains why that beats looking at the table again.
Recursion and Big-O: draw it
Recursion and algorithm analysis are where many students stall, mostly because they try to hold everything in their head.
For recursion, draw the call stack. Write each call as a box with its own parameter values, stack the boxes as calls are made, and pass return values back down as each box finishes. After a few factorial and string-reversal traces, the pattern becomes visible: statements before the recursive call run on the way down, statements after it run on the way back up.
For Big-O, count how many times the innermost line runs as the input grows. A single loop over n is O(n), nested loops multiply to O(n^2), and a loop that doubles its counter is O(log n). Big-O notation explained for beginners works through each pattern with code you can run.
A weekly rhythm that covers both halves
- Two or three coding sessions a week. Lab problems, textbook exercises, or small programs of your own. This is the skill half and nothing replaces it.
- Fifteen to twenty minutes of card review most days. Snippets, traps, vocabulary and exceptions from every unit so far, not only the current one. Mixing units is harder than reviewing one at a time and works better; see interleaving vs blocking.
- One handwritten function a week. Before exams that require code on paper, write a short function by hand, then type it in and see if it runs.
Spacing matters more than total hours. A topic reviewed for ten minutes on four separate days is usually retained better than the same forty minutes in one sitting; cramming vs spacing summarizes the research. The Pomodoro timer is a simple way to keep coding sessions focused without running long.
Where the course goes next
What's in Intro to Computer Science maps all 16 units so you can see where you are in the sequence. If you are heading toward IT, the same habits carry into certification study: how to study for Security+ SY0-701 applies retrieval and spacing to a much larger vocabulary. And the trace-every-step discipline is the same one that makes debits and credits click in accounting, where every transaction has to leave the books in balance.
The course is free, alongside the other gen-ed course flashcards on Encodr.
Encodr turns this into a habit: study anything in a feed, and it schedules the rest.
Get started free