WorksheetsIntroduction to Programming Review
Total questions: 15
Worksheet time: 15mins
Which of the following commands is a valid Karel command?
move
move;
move();
move()
What makes the following command an invalid Karel command?
turnleft();
It should end in a colon rather than a semicolon
The l should be a capital L
It should start with a capital T
This command is correct
Which of the following is the correct way to define a turnRight function in Karel?
Why do we use functions in Karel programs?
Break down our program into smaller parts
Avoid repeating code
Make our program more readable
All of the options
If Karel starts at Street 1 and Avenue 1, facing East, where will Karel be, and what direction will Karel be facing after running the following code? (Assume the world is 10x10 in size)
Street 3, Avenue 1, Facing North
Street 1, Avenue 4, Facing North
Street 1, Avenue 3, Facing South
Street 1, Avenue 3, Facing North
What’s wrong with this code?
The go function is called twice
The go function has a syntax error
The go function has been defined twice
go is not a command that Karel understands
How many total times will Karel move in this program?
(a)
What does the mystery function do?
Karel moves until it is on a ball
Karel moves once if there is no ball present
Karel moves until it puts down a ball
Karel checks if there is no ball on the current spot and then moves once
Which of the following is not a valid condition to go in an if statement for Karel?
ballsPresent()
frontIsClear()
leftIsBlocked()
turnLeft()
Why does a programmer indent their code?
Helps show the structure of the code.
Easier for other people to understand.
A key part of good programming style!
All of the options
How can we teach Karel new commands?
For loop
While loop
Define a new function
The start function
Super Karel starts at Street 1, Avenue 1, facing East in a 5x5 world. What will happen after this code runs?
Karel ends on street 1, avenue 3
Karel ends on street 2, avenue 3
This code won’t run because of a syntax error
Karel will crash into a wall
What is the purpose of using a for loop in code?
To do something if a condition is true
To do something while a condition is true
To repeat something a fixed number of times
To make programs run faster
Why do we use if/else statements in JavaScript?
To repeat something for a fixed number of times
To break out of some block of code
To do something if a condition is true and do something else if the condition is false
To repeat something while a condition is true
Which kind of conditional statement would you use to code this:
If the front is clear, Karel should move. Otherwise, Karel should turn around.
if
if, if
if/else
