Posted on

On CodeHS, the students are allowed to practice computer science concepts and programming skills by giving commands to a dog named Karel. In this learning module, Karel the dog needs to complete a variety of tasks by moving around a grid world and placing down and picking up tennis balls using only simple commands.

It is known that Karel the dog learning module actually teaches more advanced concepts using languages such as Java, JavaScript and HTML. After completing the Karel the dog module, the students will be given a series of tasks where they need to answer the questions correctly.

Of course, if the students are able to answer the questions on Karel the dog assignment for lessons 1-20 on CodeHS, they will be able to continue their learning on different module, but still regarding computer science concepts and programming skills

Code HS Karel Answers for Lessons 1 – 20

Are you looking for Karel the dog assignments? If so, you don’t have to worry, as this post will show you a series of questions and answers regardless of Karel the Dog module for the lessons 1 – 20 that we got from quizzma.com.

Here are the questions and answer keys:

1. Which is a valid Karel command?
 move; MOVE move(); move()

1. What is a street in a Karel world?

1. What is an avenue in a Karel world?

1. 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();

1. If Karel is facing North and the code turnLeft(); turnLeft(); runs; which direction is Karel facing now?

1. How many times should Karel turn left in order to turn right?

1. What can be used to teach Karel to turn right?

1. Which function will teach Karel how to spin in a circle one time?
 function spin() { turnRight(); } function spin() { turnLeft(); turnLeft(); turnLeft(); turnLeft(); } function spin() { turnLeft(); turnLeft(); } function spin() { move(); move(); move(); move(); }

 Function spin() { turnLeft(); turnLeft(); turnLeft(); turnLeft(); }
1. How many times should the start function be defined in a program?

Asnwer: 1

1. Why do we use functions in programming?

• To break down our program into smaller parts
• To avoid repeating code
• To make our program more readable
1. What is a top down design?

Answer:  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.

1. What is a code comment

1. What commands does SuperKarel know that regular Karel does not?

1. Why should a programmer indent their code?

• To help show the structure of the code
• To make it easier for other people to understand
• Indenting is a key part of good programming style
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(); }
1. Which answer choice describes the game with the lowest level of abstraction?

Answer: First, Steph Curry flexed his left and right quad muscles at the exact same time,  then he flexed each muscle in his fingers…

1. Abstraction in Karel

Answer: Abstraction helps us write programs by: When we want to create  something   such as a function/command we need to explain it in detail. Meaning we need to add less abstraction to help us understand the command in a simpler way.

Solved Assignment Problems

2.4.7 Building a Shelter Code

 turnLeft(); makeSide(); function turnRight(){ turnLeft(); turnLeft(); turnLeft();} turnRight(); makeSide();function makeSide(){ move(); putBall(); move(); putBall(); move(); putBall(); }goHome(); function goHome(){ turnRight(); move(); putBall(); move(); putBall(); move(); putBall(); turnLeft(); turnLeft(); turnLeft(); move(); move(); move(); turnLeft(); turnLeft(); }

2.5.4: Pancakes with Start

 function start(){ move(); makePancakes(); move(); move(); makePancakes(); move(); move(); makePancakes(); move(); } function makePancakes(){ putBall(); putBall(); putBall(); }

2.6.4: The Two Towers

 function start(){   move(); turnLeft(); makeTower(); move(); turnRight(); move(); move(); turnRight(); move(); makeTower(); turnLeft(); turnLeft(); move(); move(); move(); turnRight();   }   function makeTower(){ putBall(); move(); putBall(); move(); putBall(); }   function turnRight(){ turnLeft(); turnLeft(); turnLeft();   }

2.6.5: Make a ‘Z’

 function start(){ putBallsInRow(); makeDiagonal(); move(); turnAround(); putBallsInRow(); }// Puts down four balls in a row function putBallsInRow(){ move(); putBall(); move(); putBall(); move(); putBall(); move(); putBall(); }function makeDiagonal(){ turnRight(); move(); turnRight(); move(); putBall();turnLeft(); move(); turnRight(); move(); putBall();turnLeft(); move(); turnRight(); move(); }function turnRight(){ turnLeft(); turnLeft(); turnLeft(); }function turnAround(){ turnLeft(); turnLeft(); }

2.7.4: The Two Towers + Comments

 /* * Karel is going to make towers */function start(){move(); turnLeft(); makeTower(); move(); turnRight(); move(); move(); turnRight(); move(); makeTower(); turnLeft(); turnLeft(); move(); move(); move(); turnRight(); }function makeTower(){ putBall(); move(); putBall(); move(); putBall(); }function turnRight(){ turnLeft(); turnLeft(); turnLeft();}

2.9.4: The Two Towers + SuperKarel

 function start(){ //Karel will build two towers move(); turnLeft(); makeTower(); move(); turnRight(); move(); move(); turnRight(); move(); makeTower(); turnLeft(); turnLeft(); move(); move(); move(); turnRight(); } //This function will be used whenever Karel is supposed to build a tower function makeTower() { putBall(); move(); putBall(); move(); putBall(); }

2.10.5: Take ’em All

 function run(){ move(); for(var i = 0; i < 100; i++){ takeBall(); } move(); } function start(){ run(); }

2.5.5: Digging Karel with Start