Final challenge: a five-line program
After this: Predict, trace, complete and explain short programs.
This challenge has five steps, and each step is scored on its own. You will predict what a five-line program prints, follow two boxes through three lines, write the missing line of a small program, pick the line that turns text into a number, and predict a remainder and a division in your language. You can try as many times as you like, and hints work as they do in the lessons.
Step 1 of 5Predict it
Predict it
What does this print?
apples = 4pears = 3total = apples + pearsprint("Fruit: " + str(total))print(total * 2)int apples = 4;int pears = 3;int total = apples + pears;System.out.println("Fruit: " + total);System.out.println(total * 2);Trace the boxes
After the third line has run, what do x and y hold?
x = 5y = x * 2x = x + 1print(x)print(y)int x = 5;int y = x * 2;x = x + 1;System.out.println(x);System.out.println(y);Fill the line
Complete the third line so that the program prints 24: put width times height into a box named area.
width = 6height = 4____ # ← put width times height into a box named areaprint(area)int width = 6;int height = 4;____ // ← put width times height into a box named areaSystem.out.println(area);Text or number
You have the text "9" and want the number 10. Which line gives it?
Remainder and division
What does this print?
print(10 % 3)print(10 / 4)System.out.println(10 % 3);System.out.println(10 / 4);- Predict a five-line program's output, trace its boxes, fill a missing line, and tell text from numbers.