Preview

04 - Predicting Outcomes Challenge #3

 1. How many apples does Fred have in the end?
earlyyears_predicttheoutcome_test_2_apples.png

  3

  4

  2

  5

 2. Analyse the code in the image below. What number is output?
earlyyears_predicttheoutcome_test_2_algorithm_2.png

  8

  7

  5

  3

 3. Look at the code below. A user enters "153", what will the output be?
enter secret code:
if secret code = 007 then
	print("Welcome, agent")
else:
	print("Goodbye. You may not enter")

  Please enter 007 or 008

  Agent 153, Welcome

  Welcome, agent

  Goodbye. You may not enter

 4. The following code shows repetition. How could it be rewritten?
WALK 1 STEP FORWARD
WALK 1 STEP FORWARD
WALK 1 STEP FORWARD
WALK 1 STEP FORWARD
WALK 1 STEP FORWARD

  WALK 3 STEPS + 1 STEP + 3 STEPS

  WALK 1 STEP FORWARD x STEP

  Repeat 5 times (WALK 1 STEP FORWARD)

  WALK 5 STEPS + 5 STEPS + 5 STEPS

 5. What programming construct (s) are found in the following program?
Age = 12
If Age is greater than 12:
	print("You are old enough)
Else:
	print("Sorry, too young")

  Sequence and Selection (if statements)

  Repetition

  This is not a program so there are no instructions here

  Repetition (Loops) and Repeating Patterns