Please enable JavaScript to use CodeHS

New Hampshire Foundations of Computer Science

Description

In this lesson, students are introduced to CodeHS and how Karel the Dog can be given a set of instructions to perform a simple task.

Objective

Students will be able to:

  • Write their first Karel program by typing out all of the Karel commands with proper syntax

  • Explain how giving commands to a computer is like giving commands to a dog

Description

In this lesson, students learn more about Karel and Karel’s world. Students learn about walls in Karel’s world, the directions Karel can face, and how to identify a location in Karel’s world using streets and avenues. In these exercises, students will begin to see the limitations of Karel’s commands. Students will need to apply Karel’s limited set of commands to new situations. For example, how can they make Karel turn right, even though Karel does not know a turnRight command?

Objective

Students will be able to…

  • Identify the direction that Karel is facing
  • Predict what direction Karel will be facing after executing a series of commands
  • Identify a location in Karel’s world using Street, Avenue terminology
Description

In this lesson, students will learn how they can create their own commands for Karel by calling and defining functions. Functions allow programmers to create and reuse new commands that make code more readable and scalable.

Objective

Students will be able to:

  • Define a function, and successfully implement functions in their code.
  • Teach Karel a new command by creating a turnRight() function
Description

In this lesson, students learn in more detail about functions, and how they can use functions to break down their programs into smaller pieces and make them easier to understand.

Objective

Students will be able to:

  • Create functions to teach Karel new commands
  • Explain the difference between defining and calling a function
  • Utilize these functions to write higher level Karel programs that go beyond the basic toolbox of commands that Karel starts with
Description

In this lesson, students will deepen their understanding of functions by learning about the start function. The start function helps to organize the readability of code by creating a designated place where code that is going to be run in a program can be stored:

function start(){
   turnRight();
}

function turnRight(){
   turnLeft();
   turnLeft();
   turnLeft();
}
Objective

Students will be able to:

  • Explain the functionality of the start function
  • Use the start function appropriately in their programs
  • Improve the readability of their code
Description

In this lesson, students learn about Top Down Design and Decomposition. Top Down Design is the process of breaking down a big problem into smaller parts.

Objective

Students will be able to:

  • Break a large problem down into smaller, simpler problems
  • Write methods that solve the simpler problems, and use them as building blocks to solve the larger problem
  • Compare programs and identify good vs poor decomposition
Description

In this lesson, students learn how to style their programs by including comments. Comments allow students to leave notes on their program that makes it easier for other to read. Comments are written in plain English.
Commenting Your Code Example:

/*
 *  multi-line  comments
 */

// single line comments
Objective

Students will be able to:

  • Explain the preconditions and postconditions of a function
  • Create clear and readable comments in their code that help the reader understand the code
  • Explain the purpose of comments
Description

In this lesson, students will learn about abstraction. Abstraction is the act of managing complexity by dissociating information and details in order to focus on relevant concepts.

Objective

Students will be able to:

  • Understand abstraction as the different levels of detail and complexity
  • Understand the importance of abstracting away complexity to solve problems more efficiently

Enduring Understandings

This lesson builds toward the following Enduring Understandings (EUs) and Learning Objectives (LOs). Students should understand that…

  • EU 2.2 Multiple levels of abstraction are used to write programs or create other computational artifacts. (LO 2.2.3)
  • EU 4.1 Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages. (LOs 4.1.1, 4.1.2)
  • EU 4.2 Algorithms can solve many, but not all, computational problems. (LO 4.2.4)
  • EU 5.1 Programs can be developed for creative expression, to satisfy personal curiosity, to create new knowledge, or to solve problems (to help people, organizations, or society). (LOs 5.1.1, 5.1.2)
  • EU 5.2 People write programs to execute algorithms. (LO 5.2.1)
  • EU 5.3 Programming is facilitated by appropriate abstractions. (LO 5.3.1)
  • EU 5.4 Programs are developed, maintained, and used by people for different purposes. (LO 5.4.1)
Description

In this lesson, students are introduced to Super Karel! Since commands like turnRight() and turnAround() are so commonly used, students shouldn’t have to define them in every single program. This is where SuperKarel comes in. SuperKarel is just like Karel, except SuperKarel already knows how to turnRight and turnAround, so students don’t have to define those functions anymore!

Objective

Students will be able to:

  • Write programs that use SuperKarel instead of Karel
  • Utilize the new toolbox of commands that SuperKarel provides over Karel
  • Read documentation to understand how to use a library (SuperKarel is an example of this)
Description

In this lesson, students learn how to use for loops in their programs. The for loop allows students to repeat a specific part of code a fixed number of times.

For loops are written like this:

for(var i = 0; i < 4; i++)
{
    // Code to be repeated 4 times
}
Objective

Students will be able to:

  • Create for loops to repeat code a fixed number of times
  • Explain when a for loop should be a used
  • Utilize for loops to write programs that would be difficult / impossible without loops
Description

In this lesson, students learn about the conditional statement “if”. Code within an “if statement” will only execute IF the condition is true.

if (frontIsClear()) {
    // Code to be executed only if front is clear
}
Objective

Students will be able to:

  • Use conditions to gather information about Karel’s world (is the front clear, is Karel facing north, etc)
  • Create if statements that only execute code if a certain condition is true
Description

In this lesson, students learn about an additional control structure, if/else statements. If/else statements let students do one thing if a condition is true, and something else otherwise.

if/else statements are written like this:

if(frontIsClear())
 {
      // code to execute if front is clear
 }
 else
 {
      // code to execute otherwise
 }
Objective

Students will be able to:

  • Explain the purpose of an If/Else statement
  • Create If/Else statements to solve new types of problems
  • Identify when it is appropriate to use an If/Else statement
Description

In this lesson, students are introduced a new type of loop: while loops. While loops allow Karel to repeat code while a certain condition is true. While loops allow students to create general solutions to problems that will work on multiple Karel worlds, rather than just one.

Objective

Students will be able to:

  • Explain the purpose of a while loop
  • Create while loops to repeat code while a condition is true
  • Utilize while loops to solve new types of problems
  • Test their solutions on different Karel worlds
Description

In this lesson, students learn how to combine and incorporate the different control structures they’ve learned to create more complex programs.

Objective

Students will be able to:

  • Identify the different control structures we can use to modify the flow of control through a program
  • Combine control structures to solve complicated problems
  • Choose the proper control structure for a given problem
Description

In this lesson, students get extra practice with control structures. Students will continue to see different ways that the if, if/else, while, and for loops affect their code and what Karel can do.

Objective

Students will be able to:

  • Debug common errors in code
  • Use control structures to create general solutions that work on all Karel worlds
Description

In this lesson, students review how they should indent their code to make it easier to read.

Objective

Students will be able to:

  • Explain why it is important to indent code
  • Identify proper indentation
  • Modify a program to have proper indentation
  • Write programs with proper indentation
Description

Debugging is a very important part of programming. In this lesson, students learn how to effectively debug their programs.

Objective

Students will be able to use debugging strategies to find and fix errors in their code.