← Basic Web Development

Programming Readiness Test

Are you ready to move from JavaScript to Python? 46 marks, plus 3 bonus.

All the code here is JavaScript, which you already know. Read carefully and take your time.

Answer every question, then press Check my answers. You can also check one question at a time as you go. At the end you get a score, a verdict, and a list of what to go back and practise.

Marks
46
Time
about 45 minutes
Paper version
Print or hand in

Section A: Quick Concepts

Choose the best answer. One mark each.

  1. A1.What does a variable do in a program?

    1 mark
  2. A2.After this code runs, what is the value of score?

    1 mark
    let score = 10;
    score = score + 5;
  3. A3.In JavaScript, which symbol CHECKS if two values are equal?

    1 mark
  4. A4.What is the position (index) of the FIRST item in an array?

    1 mark
  5. A5.True or False: a while loop always repeats an exact number of times that you choose in advance.

    1 mark
  6. A6.In Scratch, the "repeat 10" block is most like which JavaScript idea?

    1 mark
  7. A7.What does return do inside a function?

    1 mark
  8. A8.In JavaScript, what does "5" + 5 give you?

    1 mark

Section B: Trace the Code

Write exactly what each program prints, in order. One line of output per console.log.

  1. B1.What does this print?

    2 marks
    let x = 4;
    let y = x * 2;
    x = x + 1;
    console.log(x);
    console.log(y);
  2. B2.What does this print?

    2 marks
    let age = 13;
    if (age >= 13) {
      console.log("teen");
    } else {
      console.log("kid");
    }
  3. B3.What does this print?

    3 marks
    let total = 0;
    for (let i = 1; i <= 4; i++) {
      total = total + i;
    }
    console.log(total);
  4. B4.What does this print?

    3 marks
    let count = 0;
    while (count < 3) {
      console.log("hi");
      count = count + 1;
    }
    console.log(count);
  5. B5.What does this print?

    3 marks
    let animals = ["cat", "dog", "bird"];
    console.log(animals[1]);
    console.log(animals.length);
  6. B6.What does this print?

    4 marks
    for (let i = 1; i <= 3; i++) {
      for (let j = 1; j <= 2; j++) {
        console.log(i + "-" + j);
      }
    }
  7. B7.What does this print?

    3 marks
    function double(n) {
      return n * 2;
    }
    let result = double(3) + double(5);
    console.log(result);

Section C: Spot the Bug

Each program has one bug. Say what is wrong and how you would fix it. Three marks each.

  1. C1.This should print "Welcome!" only when the password is correct, but it prints it no matter what.

    3 marks
    let password = "cat";
    if (password = "dragon") {
      console.log("Welcome!");
    }
  2. C2.This game should end when you run out of lives, but it never stops.

    3 marks
    let lives = 3;
    while (lives > 0) {
      console.log("Playing...");
    }
  3. C3.This should print the LAST colour in the list, but it prints undefined.

    3 marks
    let colors = ["red", "green", "blue"];
    console.log(colors[3]);

Section D: Write Some Code

Write JavaScript, or clear steps in plain English. Small syntax slips are fine if the logic is right.

  1. D1.Write a loop that prints the numbers 1 to 10, one per line.

    4 marks
  2. D2.Write a function called greet that takes a name and RETURNS (not prints) the text "Hello, NAME!". For example, greet("Sam") should return "Hello, Sam!".

    5 marks
  3. BONUS.Bonus. Write a function called isEven that takes a number and returns true if it is even and false if it is odd. Hint: n % 2 gives the remainder when n is divided by 2.

    3 marks

0 of 21 answered

Teacher's versionHow to use this test, and the full marking guide.

This page marks itself, which means the answers are in it. Anyone who opens the browser tools can read them. That is fine for practice and for a student checking their own work, and it is what makes the feedback possible.

For a test that is actually being graded, use the paper version. It holds no answers, and the student downloads a text file to hand in. The marking guide is deliberately not published here: this site is public, so keep your copy as a local file and grade from it there.

The written questions are marked by the student against a checklist. That is deliberate: no program grades a paragraph fairly, and reading the model answer closely enough to tick the boxes teaches more than a number would.