Font size
WorksheetsY8 Java (Karel the dog)
Total questions: 10
Worksheet time: 16mins
Which function will turn Karel around?
function turnAround()
turnLeft();
turnLeft();
turnLeft();
}
function turnAround(){
turnLeft();
turnLeft();
turnLeft();
}
function turnAround(){
turnLeft();
turnLeft();
turnleft();
}
How do we get a function to run in our program?
We write it when we want to use it in a program
We call it when we want to use it in a program
We can set a time for it to run
It runs automatically
Which is the correct code?
turnLeft();
putBall();
move():
putBall();
move();
turnLeft();
putBall()
move()
putBall:
move();
turnLeft();
putBall();
move():
putall:
move();
Karel is stood at position (dot) 0,0. What position is the dot 2 places after Karel and 1 up?
2,1
1,2
0,2
2,0
I want Karel to move, drop a ball and move once again. Which is the correct code?
function dropball(){
move();
putball();
move();
}
function dropball(){
putBall);
putBall();
move();
}
function dropball(){
move();
putBall();
move();
}
I need Karel to get to coordinate 0,3. Which code is correct?
move();
turnLeft();
move();
move();
turnLeft();
move();
move();
move();
move();
turnLeft();
move();
turnLeft();
What is the least number of times Karel needs to move forward (East) to complete this program? she starts at 0,0
2
3
4
5
Why do we use functions in a program?
Easier to find bugs/problems in a program
The program reads functions at a faster pace
Functions take less time to write
Organises the program more efficiently
Which is the correct program?
move();
turnLeft();
putBall();
move();
move();
putBall();
move(0;
turnLeft()
move();
putBall();
move();
turnLeft();
2 of the functions have bugs in them...which is correct
function move(){
turnLeft();
turnLeft();
turnLeft();
}
function move(){
turnLeft();
turnLeft();
turnLeft();
function move(){
turnleft();
turnLeft();
turnLeft();
}
