Please enable JavaScript to use CodeHS

AP Computer Science Principles in Python

Description

In this lesson, students learn about functions and parameters in the context of Python which builds on their prior knowledge of working with functions in Karel. This lesson focuses specifically on defining and calling functions, and passing simple, single parameters to functions.

Objective

Students will be able to:

  • Explain the purpose of functions
  • Define their own Python functions
  • Utilize (call) their Python functions to solve simple problems
  • Define and call functions that take in parameters as input
Description

In this lesson, students will work with and will define and call their own functions that take in multiple parameters as input and print out output.

Objective

Students will be able to:

  • Explain the purpose of functions
  • Define their own Python functions
  • Utilize (call) their Python functions to solve simple problems
  • Define functions that take in multiple parameters as input, and use print statements for output
Description

In this lesson, students continue working with multiple parameters that create graphics as output which is very useful, since creating several different graphical objects involves writing the same code over and over again (set the size, set the color, set the location, etc).

Objective

Students will be able to:

  • Explain the purpose of functions
  • Define their own Python functions
  • Utilize (call) their Python functions to simplify their graphics programs
  • Identify repeated code that can be simplified with functions and parameters
  • Define functions that take in multiple parameters as input, and create graphics as output
  • Pass parameters of the correct number and type to their defined Python functions
Description

In this lesson, students learn about return values so they can write functions that do some work and send the result back or use later in the program.

Objective

Students will be able to:

  • Explain the purpose of returning a value from a function.
  • Define functions that return values.
  • Create programs that define and call functions with return values and store the result for later use.
Description

In this lesson, students work with and define functions with return values and more than one parameter.

Objective

Students will be able to…

  • Explain the purpose of returning a value from a function.
  • Create functions that return values.
  • Create programs that call functions with return values and use the return values to solve a higher-order problem.
Description

In this lesson we explore the scoping of a variable, which is where the variable is “defined” or where it exists.

Objective

Students will be able to:

  • Identify the scope of a variable
  • Identify which variables are in scope at a given point in a program
Description

In this lesson, students explore Python’s way of handling errors with exceptions.

Objective

Students will be able to:

  • create programs that can gracefully handle exceptions
  • continue to function when an error is raised
Description

In this lesson, students will take a look behind the scenes of Karel. While they are familiar with the basic commands, this lesson explores details about how Karel’s API is created. Students will gain a better understanding of APIs while at the same time, applying graphics and function concepts.

Objective

Students will be able to:

  • Understand how an API abstracts away detail for a program such as Karel
  • Use functions and event-driven programming to create a simple API
Description

Use your knowledge of basic Python to create some fun programs! Students will create their own Ghost drawings from Pac-Man, a Guessing Game, and a drawing of their own choosing. This will allow students to get creative with their code to show what they have learned.

Objective

Students will be able to…

  • Synthesize the skills and concepts from the Python and Graphics, Python Control Structures, and the Functions and Parameters units to solve increasingly difficult programming challenges
  • Break down a large problem into smaller parts using Top Down Design, and solve each of these smaller parts using functions
  • Create helpful comments with preconditions and postconditions to help the reader understand the code
  • Find and fix bugs in large programs
Description

This lesson is a summative assessment of the unit’s learning objectives.

Objective

Assess student achievement of the learning goals of the unit