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.
A1.What does a variable do in a program?
1 markA2.After this code runs, what is the value of
1 markscore?let score = 10; score = score + 5;A3.In JavaScript, which symbol CHECKS if two values are equal?
1 markA4.What is the position (index) of the FIRST item in an array?
1 markA5.True or False: a
1 markwhileloop always repeats an exact number of times that you choose in advance.A6.In Scratch, the "repeat 10" block is most like which JavaScript idea?
1 markA7.What does
1 markreturndo inside a function?A8.In JavaScript, what does
1 mark"5" + 5give you?
Section B: Trace the Code
Write exactly what each program prints, in order. One line of output per console.log.
B1.What does this print?
2 markslet x = 4; let y = x * 2; x = x + 1; console.log(x); console.log(y);B2.What does this print?
2 markslet age = 13; if (age >= 13) { console.log("teen"); } else { console.log("kid"); }B3.What does this print?
3 markslet total = 0; for (let i = 1; i <= 4; i++) { total = total + i; } console.log(total);B4.What does this print?
3 markslet count = 0; while (count < 3) { console.log("hi"); count = count + 1; } console.log(count);B5.What does this print?
3 markslet animals = ["cat", "dog", "bird"]; console.log(animals[1]); console.log(animals.length);B6.What does this print?
4 marksfor (let i = 1; i <= 3; i++) { for (let j = 1; j <= 2; j++) { console.log(i + "-" + j); } }B7.What does this print?
3 marksfunction 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.
C1.This should print "Welcome!" only when the password is correct, but it prints it no matter what.
3 markslet password = "cat"; if (password = "dragon") { console.log("Welcome!"); }C2.This game should end when you run out of lives, but it never stops.
3 markslet lives = 3; while (lives > 0) { console.log("Playing..."); }C3.This should print the LAST colour in the list, but it prints
3 marksundefined.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.
D1.Write a loop that prints the numbers 1 to 10, one per line.
4 marksD2.Write a function called
5 marksgreetthat takes a name and RETURNS (not prints) the text "Hello, NAME!". For example,greet("Sam")should return "Hello, Sam!".BONUS.Bonus. Write a function called
3 marksisEventhat takes a number and returnstrueif it is even andfalseif it is odd. Hint:n % 2gives the remainder whennis divided by 2.
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.