Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INTRODUCTION TO PROGRAMMING
- ===================================
- MODULE I: INTRODUCTION TO PROGRAMMING WITH KAREL
- ===================================
- QUIZ: KAREL COMMANDS
- Which of these is a valid Karel command?
- - move();
- ===================================
- 2.1.4: YOUR FIRST KAREL PROGRAM
- move();
- move();
- move();
- takeBall();
- ===================================
- 2.1.5: SHORT STACK
- move();
- putBall();
- putBall();
- move();
- ===================================
- 2.1.6: DANCING KAREL
- move();
- move();
- turnLeft();
- turnLeft();
- turnLeft();
- turnLeft();
- ===================================
- MODULE II: MORE BASIC KAREL
- ===================================
- QUIZ: MORE BASIC KAREL
- Question: 1
- If Karel is facing North and the code
- turnLeft();
- turnLeft();
- runs, which direction is Karel facing now?
- - South
- Question: 2
- If Karel starts at Street 1 and Avenue 3 facing East, what street (row) and avenue (column) will Karel be on after this code runs?
- move();
- move();
- move();
- turnLeft();
- move();
- - Street 2 and Avenue 6
- Question: 3
- What is an avenue in a Karel world?
- - A column
- Question: 4
- What is a street in a Karel world?
- - A row
- ===================================
- 2.2.4: MAKE A TOWER
- move();
- putBall();
- turnLeft();
- move();
- putBall();
- move();
- putBall();
- move();
- turnLeft();
- turnLeft();
- turnLeft();
- ===================================
- 2.2.5: PYRAMID OF KAREL
- putBall();
- move();
- putBall();
- turnLeft();
- move();
- putBall();
- turnLeft();
- turnLeft();
- move();
- turnLeft();
- move();
- putBall();
- turnLeft();
- move();
- putBall();
- move();
- putBall();
- turnLeft();
- turnLeft();
- turnLeft();
- ===================================
- 2.2.6: GO THROUGH THE DOOR
- turnleft();
- move();
- move();
- turnLeft();
- turnLeft();
- turnLeft();
- move();
- move();
- move();
- turnLeft();
- turnLeft();
- turnLeft();
- move();
- turnLeft();
- move();
- ===================================
- MODULE III: KAREL CAN'T TURN RIGHT
- ===================================
- QUIZ: KAREL CAN'T TURN RIGHT
- Question: 1
- What can be used to teach Karel to turn right?
- - Functions
- Question: 2
- How many times should Karel turn left in order to turn right?
- - 3
- ===================================
- 2.3.4: SLIDE KAREL
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- putBall();
- move();
- turnRight();
- move();
- putBall();
- move();
- turnLeft();
- move();
- putBall();
- move();
- ===================================
- 2.3.5: FIREMAN KAREL
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- turnRight();
- move();
- move();
- move();
- turnLeft();
- ===================================
- 2.3.6: REFLECTION: TEACHING KAREL TO TURN RIGHT
- ***INDIVIDUAL ASSIGNMENT***
- ===================================
- MODULE IV: FUNCTIONS IN KAREL
- ===================================
- QUIZ: FUNCTIONS IN KAREL
- Which function will teach Karel how to spin in a circle one time?
- [A]
- function spin() {
- turnRight();
- }
- [B]
- function spin() {
- turnLeft();
- turnLeft();
- turnLeft();
- turnLeft();
- }
- [C]
- function spin() {
- turnLeft();
- turnLeft();
- }
- [D]
- function spin() {
- move();
- move();
- move();
- move();
- }
- - B
- ===================================
- 2.4.4: PANCAKES
- function start(){
- makePancakes();
- makePancakes();
- makePancakes();
- }
- function makePancakes(){
- move();
- putBall();
- putBall();
- putBall();
- move();
- }
- ===================================
- 2.4.5: BACKFLIP
- function start(){
- backflip();
- backflip();
- }
- function backflip(){
- move();
- turnLeft();
- turnLeft();
- turnLeft();
- turnLeft();
- move();
- }
- ===================================
- 2.4.6: DIGGING KAREL
- function start(){
- buryBall();
- buryBall();
- buryBall();
- }
- function buryBall(){
- move();
- move();
- turnRight();
- move();
- move();
- move();
- putBall();
- turnAround();
- move();
- move();
- move();
- turnRight();
- move();
- }
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- function turnAround(){
- turnLeft();
- turnLeft();
- }
- ===================================
- 2.4.7: BUILD A SHELTER
- function start(){
- turnLeft();
- makeSide();
- turnRight();
- makeSide();
- turnRight();
- makeSide();
- goHome();
- }
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- function makeSide(){
- move();
- putBall();
- move();
- putBall();
- move();
- putBall();
- }
- function goHome(){
- turnRight();
- move();
- move();
- move();
- turnLeft();
- turnLeft();
- }
- ===================================
- MODULE V: THE START FUNCTION
- ===================================
- QUIZ: THE START FUNCTION
- How many times should you call the start function when writing your program?
- - 0
- How many times should the start function be defined in a program?
- - 1
- ===================================
- 2.5.4: PANCAKES WITH START
- function start(){
- makePancakes();
- makePancakes();
- makePancakes();
- }
- function makePancakes(){
- move();
- putBall();
- putBall();
- putBall();
- move();
- }
- ===================================
- 2.5.5: DIGGING KAREL WITH START
- function start(){
- buryBall();
- buryBall();
- buryBall();
- }
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- function buryBall(){
- move();
- move();
- turnRight();
- move();
- move();
- move();
- putBall();
- turnLeft();
- turnLeft();
- move();
- move();
- move();
- turnRight();
- move();
- }
- ===================================
- MODULE VI: TOP DOWN DESIGN AND DECOMPOSITION WITH KAREL
- ===================================
- QUIZ: TOP DOWN DESIGN AND DECOMPOSITION
- Question: 1
- Why do we use functions in programming?
- - All of the above
- Question: 2
- 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.
- ===================================
- 2.6.4: THE TWO TOWERS
- function start(){
- makeTower();
- move();
- move();
- turnLeft();
- move();
- makeTower();
- move();
- turnRight();
- }
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- function makeTower(){
- move();
- putBall();
- turnLeft();
- move();
- putBall();
- move();
- putBall();
- }
- ===================================
- 2.6.5: MAKE A 'Z'
- function start(){
- putBallsInRow();
- makeDiagonal();
- move();
- turnLeft();
- turnLeft();
- putBallsInRow();
- }
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- // PLACES FOUR BALLS IN A ROW
- function putBallsInRow(){
- move();
- putBall();
- move();
- putBall();
- move();
- putBall();
- move();
- putBall();
- }
- // MAKES A DIAGONAL LINE OF BALLS
- function makeDiagonal(){
- turnRight();
- move();
- turnRight();
- move();
- putBall();
- turnLeft();
- move();
- turnRight();
- move();
- putBall();
- turnLeft();
- move();
- turnRight();
- move();
- }
- ===================================
- REFLECTION: TOP-DOWN DESIGN
- *** INDIVIDUAL ASSIGNMENT ***
- ===================================
- MODULE VII: COMMENTING YOUR CODE
- ===================================
- QUIZ: COMMENTING YOUR CODE
- Question: 1
- What is a code comment?
- - A way to give notes to the reader to explain what your code is doing
- ===================================
- 2.7.4: THE TWO TOWERS + COMMENTS
- // FUNCTION START() MAKES THE PROGRAM RUN AND MAKE TOWERS ONE AND TWO
- function start(){
- makeTower();
- move();
- move();
- turnLeft();
- move();
- makeTower();
- move();
- turnRight();
- }
- // MAKES KAREL TURN RIGHT USING THREE LEFT TURNS
- function turnRight(){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- // KAREL DRAWS A TOWER
- function makeTower(){
- move();
- putBall();
- turnLeft();
- move();
- putBall();
- move();
- putBall();
- }
- ===================================
- REFLECTION: COMMENTING
- *** INDIVIDUAL ASSIGNMENT ***
- ===================================
- MODULE VII: ABSTRACTION
- ===================================
- QUIZ: ABSTRACTION
- Question: 1
- Karel needs to pick up a pile of tennis balls.
- Which of the following start functions solves the problem at the highest level of abstraction?
- - function start() {
- moveToPile();
- takePile();
- }
- Question: 2
- Each of the following answer choices describes a basketball game.
- Which answer choice describes the game with the lowest level of abstraction?
- - First, Steph Curry flexed his left and right quad muscles at the exact same time, then he flexed each muscle in his fingers…
- ===================================
- 2.8.4: ABSTRACTING YOUR DAY
- *** INDIVIDUAL ASSIGNMENT ***
- ===================================
- 2.8.5: REFLECTION: ABSTRACTION
- *** INDIVIDUAL ASSIGNMENT ***
- ===================================
- 2.8.6: ABSTRACTION IN KAREL
- *** INDIVIDUAL ASSIGNMENT ***
- ===================================
- MODULE IX: SUPER KAREL
- ===================================
- QUIZ: SUPER KAREL
- Question: 1
- What commands does SuperKarel know that regular Karel does not?
- - turnAround() and turnRight()
- ===================================
- 2.9.4: THE TWO TOWERS + SUPER KAREL
- // THE START FUNCTION MAKES THE PROGRAM RUN
- function start(){
- makeTower();
- move();
- move();
- turnLeft();
- move();
- makeTower();
- turnAround();
- move();
- turnRight();
- }
- // KAREL PLACES BALLS IN A TOWER
- function makeTower(){
- move();
- putBall();
- turnLeft();
- move();
- putBall();
- move();
- putBall();
- turnAround();
- }
- ===================================
- MODULE X: FOR LOOPS
- ===================================
- QUIZ: FOR LOOPS
- Question: 1
- What is the best way for Karel to move 10 times?
- - for (var i = 0; i < 10; i++) {
- move();
- }
- ===================================
- 2.10.5: TAKE 'EM ALL
- function start(){
- move();
- for(var i = 0; i < 100; i++){
- takeBall();
- }
- move();
- }
- ===================================
- 2.10.6: DIZZY KAREL
- // KAREL SPINS FOR ALL INSTANCES EQUAL TO AND LESS THAN 32
- function start(){
- for(var i = 0; i < 32; i++){
- turnLeft();
- }
- }
- ===================================
- 2.10.7: FOR LOOP SQUARE
- /* TRY TO LAY DOWN A SQUARE OF FOUR TENNIS BALLS
- * USING A FOR LOOP
- */
- function start(){
- for(var i = 0; i < 4; i++){
- putBall();
- move();
- turnLeft();
- }
- }
- ===================================
Add Comment
Please, Sign In to add comment