Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

U5L13 - Pseudocode Homework (Conditionals & Loops)

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Consider a robot who would like to move in an “L” shape. Which of the following code segments will allow the robot to move in an L shape, assuming the path is clear?

a)

MOVE_FORWARD()

MOVE_FORWARD()

ROTATE_LEFT()

ROTATE_LEFT()

ROTATE_LEFT()

MOVE_FORWARD()

b)

MOVE_FORWARD()

ROTATE_RIGHT()

MOVE_FORWARD()

MOVE_FORWARD()

c)

MOVE_FORWARD()

MOVE_FORWARD()

ROTATE_LEFT()

ROTATE_LEFT()

MOVE_FORWARD()

d)

MOVE_FORWARD()

MOVE_FORWARD()

ROTATE_LEFT()

ROTATE_LEFT()

MOVE_FORWARD()

2.

Consider the code segment.

For the initial situation above, what will be the final position and direction of the robot after the code is executed?

a)
b)
c)
d)
3.

Consider the code segment.

For the initial situation above, what will be the final position and direction of the robot after the code is executed?

a)
b)
c)
d)
4.

The code above does not run as intended for the robot in the initial scenario given. Which reason below explains the error?

a)

The initial condition is not met, so the code in the REPEAT UNTIL loop is not executed.

b)

The robot backs up, then does not move.

c)

The program terminates when the robot attempts to move off the grid.

d)

There is an infinite loop.

5.

For the initial scenario above, what will be the final position and direction of the robot after the code is executed?

a)
b)
c)

The program terminates when the robot attempts to move off the grid.

d)

There is an infinite loop.

6.

Consider the code segment here.

Which of the following are possible outcomes of the code? SELECT TWO ANSWERS.

a)

The robot will move forward.

b)

The robot will return to its original position.

c)

The robot will be in a position in which it can move forward.

d)

The robot will get stuck in an infinite loop.

7.

What will be the final location and direction of the robot after the code segment is run?

a)
b)
c)
d)
8.

Consider the incorrect code segment here, meant to guide a robot through the maze.

In order to find out why the code is not working, the programmer views the robot at different points in the code. Immediately after which point will the robot not move as expected?

a)
b)
c)
d)
9.

How many times will the loop be executed?

a)

The loop will not execute.

b)

3

c)

6

d)

There is an infinite loop.

10.

Assuming that a and b are integers, and b is less than zero, what can we assume is true after the code is executed? SELECT TWO ANSWERS.

a)

a must always be negative

b)

a may be zero

c)

a must be less than b

d)

a must equal b