Programming Readiness Test
This test shows whether you are ready to move from JavaScript to Python. 46 marks, plus 3 bonus.
All the code here is JavaScript. You already know it. Read carefully and take your time.
Answer every question. Then click 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 practise again.
- 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. Each console.log prints one line.
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. Then say 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. It prints
3 marksundefinedinstead.let colors = ["red", "green", "blue"]; console.log(colors[3]);
Section D: Write Some Code
Write JavaScript, or write 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. It must return the text "Hello, NAME!". It must not print it. For example,greet("Sam")should return "Hello, Sam!".BONUS.Bonus. Write a function called
3 marksisEventhat takes a number. It returnstrueif the number is even. It returnsfalseif the number 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, so 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. Keeping the answers here is what makes the feedback possible.
For a test you are really grading, use the paper version. It holds no answers. The student downloads a text file to hand in. This site is public, so it does not publish the marking guide. Keep your copy as a local file and grade from that.
The student marks the written questions against a checklist. That is on purpose. No program grades a paragraph fairly. To tick the boxes, the student has to read the model answer closely. That teaches more than a number would.