Real World Programming - Functions
How many times should the start function be called in a program?
0
How many times should the start function be defined in a program?
1
In the following code snippet, how many times is the turnRight function called and how many times is it defined? move(); turnLeft(); move(); turnRight(); turnRight(); move(); turnRight(); function turnRight() { turnLeft(); turnLeft(); turnLeft(); }
Called 3 times, defined 1 time
Why do we use functions in programming? A. Break down our program into smaller parts B. Avoid repeating code C. Make our program more readable D. All of the above
D
What is top down design?
Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.
Which function will teach Karel how to spin in a circle one time? - Hint: Use "function spin() {"
function spin() { turnLeft(); turnLeft(); turnLeft(); turnLeft(); }