All articles

How to Study for a Computer Science Exam: Code on Paper

Published November 25, 2026

To study for a computer science exam, practise the way you will be tested. Write code by hand under a time limit, trace programs line by line on paper, explain the main concepts out loud without notes and keep a log of the bugs you keep making. Reading your lecture slides again, or watching the code run on a screen, gives a comfortable feeling of understanding that disappears the moment the page in front of you is blank.

This matters because computer science is unusual among school and university subjects. Most of your learning happened with a computer helping you: syntax highlighting, autocomplete, instant error messages, search. Many exams remove all of that. You get a sheet of paper, a question and a clock. This guide shows how to prepare for that situation and how to cover the theory part of the exam too.

Find out exactly how you will be tested

Computer science exams differ a lot, so start by listing the question types. Typical ones are:

  • Writing a function or a short program from a description.
  • Reading code and saying what it prints or returns, which is called tracing.
  • Finding and fixing a bug in a given piece of code.
  • Short theory questions about complexity, data structures, memory, networks or databases.
  • Multiple choice on definitions and small code snippets.
  • Larger design questions, such as choosing a data structure for a problem and justifying it.

Check the format. Is it on paper or on a computer? Is any reference sheet, cheat sheet or open book allowed? Is the language fixed? How are marks split between code and explanation? Past papers answer most of this. If your course publishes old exams, get them now. Our guide to using past papers explains how to work through them in a useful order.

Then turn the syllabus into a list of topics, and rate each one as strong, shaky or weak using real questions. Most of your time should go to the shaky and weak ones.

Write code by hand, under exam conditions

The biggest gap for most students is between coding at a keyboard and coding on paper. At a keyboard you fix small errors without noticing: a missing bracket, a wrong variable name, an off-by-one in a loop. On paper nobody fixes them, and the marker sees every one.

The remedy is simple and uncomfortable. For each major topic, do this.

  • Pick a problem from a lecture, a lab or a past paper.
  • Set a timer based on the marks, and write the full solution by hand with no notes and no computer.
  • Only then type it in, run it and test it.
  • Compare. Every difference between your paper version and the working version is something to learn from.

Write the errors down. Typical ones are missing return statements, wrong loop bounds, forgetting to initialise a variable, mixing up the order of arguments and using a method name that does not exist. These slips are what cost marks, and they are invisible until you write on paper.

Stanford's CS111 course staff give the same advice in their exam guidance: take a problem and write out your solution under test-like conditions (Stanford CS111 exam advice). Do a few of these every week, not one big batch in the last days.

Do not worry about perfect syntax in the early attempts. If you do not remember a library call, write a comment of what it should do, finish the solution and look it up afterwards. Then add the call to a list of syntax to memorise.

Learn to trace code until it is boring

Tracing means running a program in your head, or rather on paper, and writing down what it does. It is one of the most common exam questions and one of the best ways to understand a program. It is also where many students lose easy marks, because they try to do it in their heads.

Here is a method that works.

  • Make a table. Give each variable its own column and each step its own row.
  • Go line by line, and update the table every time a value changes. Never skip a line, even if it looks obvious.
  • For loops, write the value of the counter on each pass. For conditions, write whether the test was true or false.
  • For functions, draw a small box for each call with its own arguments and local variables.
  • For recursion, stack the boxes and write the return value as each one finishes.

Start with short examples: a loop that sums a list, a nested loop that prints a pattern, a function that reverses a string. Then increase the difficulty with recursion, pointers or objects, depending on your course. After each trace, run the code and compare your table with the real output. Any mismatch points to a misunderstanding of the language, which is exactly what you want to find before the exam.

Make the concepts explainable

Theory questions ask for definitions and reasoning: what is the difference between a stack and a queue, why is binary search faster than linear search, what does a primary key do, what is a race condition. Rereading slides does not prepare you to answer these, because the exam asks you to produce the explanation from memory.

Roediger and Karpicke (2006) tested this directly. Students who practised recalling a text remembered more a week later than students who studied it again, even though the rereaders felt more prepared (the study). For computer science, recall can take several forms.

  • Explain it aloud. Pick a concept, close your notes and explain it as if teaching a friend. Where you hesitate is where you need work.
  • Draw it. Sketch a linked list, a binary tree, a hash table or a network diagram from a blank page and label what happens on insertion or lookup.
  • Compare pairs. Write the differences between concepts that are often confused: arrays and linked lists, processes and threads, TCP and UDP, SQL joins.
  • Give an example. For each concept, write a small example of when you would use it and when you would not.

For complexity, learn to read it from the code. A single loop over n items is linear. A loop inside a loop over the same data is usually quadratic. Halving the problem each step is logarithmic. Practise with five or six snippets until you can say the complexity and the reason in a sentence.

Our guide to active recall explains the idea in more depth, and it fits computer science well, because every concept can be turned into a question.

Orbily can help with part of this. You can import your notes or lecture slides as a chapter, and its Active Recall tool turns the chapter into multiple-choice questions with a short explanation after each answer. That is useful for definitions and small facts, such as what a term means or which structure fits a situation. It does not teach you to write or trace code, so keep your hand-written practice for that. You can read more about Active Recall.

Memorise what must be memorised

Some things really do have to be in your head: the syntax of loops and conditions, how to declare a function or a class, the common methods of strings, lists and dictionaries, the usual SQL keywords, the main steps of the algorithms in your course. Make a short list for your course and learn it with spaced practice.

  • Write each item as a question on a card: "Syntax of a for loop over a list in Python?" or "What does `pop` do on a stack?"
  • Answer from memory, check, and put the cards you missed back into the pile.
  • Review a little every day for a couple of weeks. Cepeda and colleagues (2006) reviewed many experiments and found that spreading practice over several sessions improves long-term retention compared with the same time in one block (the review).

Keep the list short. A dozen well-chosen syntax patterns learned perfectly are worth more than a hundred half-remembered ones.

Keep a bug log

A bug log is a page where you write every mistake you make in practice and its cause. Examples: "off-by-one: used `<=` instead of `<`", "forgot to handle the empty list", "changed a list while looping over it", "confused the index with the value", "wrote `=` instead of `==`".

Review the log before each practice session and again the day before the exam. After a couple of weeks, three or four patterns usually account for most of your errors, and fixing those is worth more than learning a new topic. The same habit is at the heart of the guide on how to correct a practice exam yourself.

When you meet an error you cannot explain, do not just fix it. Write a one-sentence rule for yourself, such as "Always check the empty case first". Rules like these are what you will use on exam day.

Study with others, but do it actively

A study group can be very useful in computer science if it is used well. Each person writes a couple of questions or small coding tasks, and the others solve them on paper. Then you compare and explain different approaches. Explaining your solution to someone else shows you what you did not really understand.

Avoid the version where one person solves everything on the board and the others nod. That feels productive and teaches little. If you cannot find a group, explain to an imaginary student or record yourself for two minutes.

An exam-prep plan for three weeks

If you have about three weeks, this rhythm works.

  • Week 1: List topics and rate them. Rewrite the syntax list and start daily card review. Do topic-by-topic hand-written exercises on the weakest topics, with the notes open at first.
  • Week 2: Switch to closed notes. Do traces and short programs on paper under a timer. Explain two or three concepts aloud each day. Start your bug log.
  • Week 3: Do full past papers on paper, timed, then mark them with the official scheme. Update the log. In the last two days, review only the cards, the log and the concepts you still hesitate on. Do not start new topics.

If you have a week or less, drop depth in the strong topics and use past papers, hand-written code and tracing as your main work. See how to revise for an exam in a week for a day-by-day version, and compare with the approach in our guide to studying for a math exam, which shares the same logic of practising problems instead of rereading.

If the exam is open book

An open book or open notes exam can be a trap. It tempts you to study less, but the questions are usually harder, since the examiners know you can look things up. Spend your time on practice, not on copying more into your notes. Organise the notes so you can find a topic in a few seconds: clear headings, an index of page numbers and a short sheet of the patterns you use most. Practise with that exact set of notes, timed, so you know where things are. Our guide to open book exams goes deeper.

On exam day

Skim the whole paper first and start with the questions you can answer well. Plan your time by marks, and do not spend half the exam on a single difficult function. For code questions, read the specification twice and write a short comment plan first: inputs, outputs, edge cases, steps. Then write the code, and finish by tracing it on one simple example and one edge case, such as an empty list or a zero. If you get stuck, write what you can, move on and return later. Our guide on managing time during an exam has more on pacing.

Leave a few minutes at the end for brackets, colons, indentation and variable names. These are the small things you learned to catch on paper. If you have practised writing and tracing code by hand, explaining the concepts aloud and fixing the patterns in your bug log, the exam will look like something you have done many times before.

FAQ

For the core of the language, yes. If the exam is on paper with no reference sheet, you need to write loops, conditions, function definitions and common library calls without help. Check whether a cheat sheet or reference is allowed, and practise exactly under those conditions.

Take a problem from a lecture or past paper, set a timer and write the solution by hand on paper. Then type it in, run it and compare. The errors the computer finds show you which habits only work with an editor and autocomplete helping you.

Make a table with one column per variable and one row per step. Update it line by line, never in your head. Start with short loops and conditions, then move to functions and recursion. Check your table by running the code and compare each value.

You still need to study. Open notes save you from remembering small details, but they do not write the solution. Organise your notes so you can find things in seconds and practise with them, because searching a big pile of pages costs time you will not have.

Start about three weeks ahead if you can. Programming skill grows with repeated practice over days, not with one long night. With less time, focus on past papers, hand-written code and the topics you miss most often.