Please enable JavaScript to use CodeHS

AP Computer Science A (Nitro)

Description

In this lesson, students will learn how and when to use a while loop. Repetitive code can be avoided by using a while loop. While loops are used to repeat a set of statements until a condition is met. This lesson corresponds with AP Computer Science A topic 4.1.

Objective

Students will be able to:

  • Represent iterative processes using a while loop
  • Execute a return or break statement inside an iteration statement to halt the loop and exit the method or constructor
  • Develop an algorithm
  • Identify if an integer is or is not evenly divisible by another integer
  • Determine a minimum or maximum value
  • Compute a sum, average, or mode
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(int i = 0; i < 4; i++)
{
    // Code to be repeated 4 times
}

This lesson corresponds with AP Computer Science A topic 4.2.

Objective

Students will be able to:

  • Represent iterative processes using a for loop
Description

In this lesson, students will learn how to develop algorithms using Strings. Students will traverse Strings using a for loop and the print.length() command.

for(int i = 0; i < string.length(); i++)
{
    String character = string.substring(i, i+1);
}

This lesson corresponds with AP Computer Science A topic 4.3.

Objective

Students will be able to:

  • Develop an algorithm using Strings
  • Find if one or more substrings has a particular property
  • Determine the number of substrings that meet specific criteria
  • Create a new string with the characters reversed
Description

In this lesson, students will learn about nested loops. Nested loops are when loops are placed inside other loops to create more complex programs. When a loop is nested inside another loop, the inner loop must complete all its iterations before the outer loop can continue. This lesson corresponds with AP Computer Science A topic 4.4.

Objective

Students will be able to:

  • Represent nested iterative processes

Enduring Understandings

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

  • EU Con-2 Programmers incorporate iteration and selection into code as a way of providing instructions for the computer to process each of the many possible input values. (LO’s 2.C, 2.D, 2.E, 2.F, 2.G)
Description

In this lesson, students will examine the concept of informal code analysis. This includes an algorithm’s correctness, efficiency and the ability to be understood. This lesson corresponds with AP Computer Science A topic 4.5.

Objective

Students will be able to:

  • Compute statement execution counts of iterative statements
  • Compute informal run-time comparison of iterative statements