Preview

04 - Predicting outcomes challenge #3

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

  3

  2

  5

  4

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

  7

  3

  8

  5

 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")

  Goodbye. You may not enter

  Welcome, agent

  Please enter 007 or 008

  Agent 153, Welcome

 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

  Repeat 5 times (WALK 1 STEP FORWARD)

  WALK 1 STEP FORWARD x STEP

  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")

  This is not a program so there are no instructions here

  Repetition (Loops) and Repeating Patterns

  Sequence and Selection (if statements)

  Repetition