aımnova
DashboardMy LearningCrash CoursesStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Crash Courses
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Teachers
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aımnova

IB study, practice and feedback built around the real exam.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.c1e448f

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer ScienceTopic 6.3Sequence
Back to Computer Science Topics
6.3.16 min read

Sequence

IB Computer Science · Unit 6

AI-powered feedback

Stop guessing — know where you lost marks

Get instant, examiner-style feedback on every answer. See exactly how to improve and what the markscheme expects.

Try It Free

Contents

  1. 1Order is not a detail
  2. 2Three ways order goes wrong
  3. 3Getting the order right first time
  4. 4Exam-style question
The big idea: Instructions run one after another, in the order written.

So two correct instructions in the wrong order give a wrong program — and nothing warns you, because both lines are perfectly valid.
# Wrong order
total = total + price
price = price * 1.2        # tax added AFTER it was counted

# Right order
price = price * 1.2        # tax added first
total = total + price
// Wrong order
total = total + price;
price = price * 1.2;        // tax added AFTER it was counted

// Right order
price = price * 1.2;        // tax added first
total = total + price;
The general rule: A value must be set before it is used, and used before it is changed again.

Most sequence errors are one of those two, and both are invisible to the computer.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
1

Infinite loop

The thing the loop is waiting for never changes.

Usually the counter is increased inside a branch that does not always run, or not at all. The program does not crash — it simply never finishes.

2

Incorrect output

Everything runs, and the answer is wrong.

A total printed before the last value was added, or an average calculated before the final mark arrived. This is the quiet one.

3

Deadlock

Two parts of a program each hold something the other is waiting for, so neither can move.

One holds the file and wants the printer; the other holds the printer and wants the file. Both wait forever.

# Infinite loop: count only increases when the value is large
count = 0
while count < 5:
    value = get_next()
    if value > 10:
        count = count + 1     # small values never advance it

# Incorrect output: printed before the last addition
for mark in marks:
    print("Total so far:", total)   # one value behind, every time
    total = total + mark
// Infinite loop: count only increases when the value is large
int count = 0;
while (count < 5) {
    int value = getNext();
    if (value > 10) {
        count = count + 1;    // small values never advance it
    }
}

// Incorrect output: printed before the last addition
for (int mark : marks) {
    System.out.println("Total so far: " + total);   // one value behind, every time
    total = total + mark;
}
Avoiding deadlock: The standard fix is to make every part claim shared resources in the same fixed order — always the file first, then the printer.

If nobody can be holding the second while waiting for the first, the circle cannot form.

Trace it like this: one row per line, and each variable keeps its value until a line changes it.

Two orders of the same three assignments traced line by line
The same three lines in two orders give b = 5 or b = 12

Practice with exam-style questions

Answer exam-style questions and get AI feedback that shows you exactly what examiners want to see in a full-marks response.

Try Practice FreeYour first topic is free to keep • No credit card required

Before the loop

  • Set up anything the loop will use: totals at 0, counters at their start
  • Read anything needed to decide how many times to go round
  • Setting a total inside the loop resets it every time

Inside the loop

  • Do the work for one item
  • Update whatever the loop's test depends on — every time round
  • Ask: could this line ever fail to run?

After the loop

  • Print or return the finished result
  • Printing inside the loop shows a running value, not the final one
  • Divide for an average here, once the count is complete
The three-question check: Is every value set before it is used? Does the loop's test always change? Is the result used after it is complete, not during?

Three questions catch nearly every sequence error there is.

How this is tested — you must say WHICH line is in the wrong place and what the effect is. It comes up two ways:

Paper 2 — working with code

  • Identify and correct a sequence error, 3-5 marks
  • Explain why a loop never ends
  • Put given instructions into the right order

Paper 2 — the algorithmic-thinking question

  • Reason about ordering with no code shown
  • Explain how deadlock arises and how to prevent it
The classic trap: Saying "the order is wrong" without naming the line. Marks come from which line, where it should go, and what the wrong order produced — one value behind, a loop that never ends.
IB-style questionIdentify[5 marks]

This should print the average mark but prints a smaller number. Find and correct the error.

total = 0 count = 0 for mark in marks: count = count + 1 print(total / count) total = total + mark

Model answer plan

See the answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic
IB-style questionIdentify[5 marks]

This should print the average mark but prints a smaller number. Find and correct the error.

int total = 0; int count = 0; for (int mark : marks) { count = count + 1; System.out.println((double) total / count); total = total + mark; }

Model answer plan

See the answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Sequence. Write your answer and get instant AI feedback — just like a real IB examiner.

the output of this Python code.

a = 3
a = 10
b = a + 2
print(b)
[2 marks]

Related Computer Science Topics

Continue learning with these related topics from the same unit:

6.1.1Variables and data types6.1.2Substrings6.1.3Exception handling6.1.4Debugging
View all Computer Science topics
Improve your exam techniqueCommand terms, paper structure, and mark-scheme tips for Computer Science
Previous6.2.4Queues (FIFO)NextSelection6.3.2

28 exam-style questions ready for you

Students who practice on Aimnova improve their scores by 15% on average. Get instant feedback that shows exactly how to improve your answers.

Practice Now — FreeView All Computer Science Topics