Please enable JavaScript to use CodeHS

Utah Introduction to Python 2

Description

In this lesson, students are introduced to lists. They learn why lists are used in programs and how to create them. Lists are created like this:

list_name = [item_1, item_2, item_3, ...]
Objective

Students will be able to:

  • Explain why lists are useful in programs
  • Create lists with items of various types
Description

In this lesson, students learn about the positive and negative indexing system of lists and how items are accessed in a list.

Objective

Students will be able to:

  • Provide two index values (positive and negative) for any item in a list
  • Access individual items in a list using index values
Description

In this lesson, students learn how to update items in lists using the index value of the item.

Objective

Students will be able to:

  • Use the index value of an item to update the contents of the item in a list
Description

In this lesson, students learn various ways to add items to an existing list with the use of the insert, extend, and append methods.

Objective

Students will be able to:

  • Use the append method to add a new item to the end of a list
  • Use the extend method to add new items to the end of a list
  • Use the addition operator (+) to add two lists together
  • Use the insert method to add a new item at a specific index in a list
Description

In this lesson, students learn various ways to remove items from an existing list with the use of the pop and remove methods and the del keyword.

Objective

Students will be able to:

  • Use the pop method with no argument to remove an item from the end of a list
  • Use the pop method to remove an item from a specific index in a list
  • Use the remove method to remove a specific item from a list
  • Use the del keyword to remove an item from a specific index in a list
Description

In this lesson, students learn how to use two new methods, sort and reverse, to alter list items.

Objective

Students will be able to:

  • Use the sort method to organize items in a list by value
  • Use the reverse method to reverse the order of items in a list
Description

In this lesson, students review content with a 10 question End-of-Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of the following commands and concepts through a multiple choice quiz:
    • Creating lists (list_name = [item_1, item_2, ...])
    • Index values
    • Accessing list items (list_name[index])
    • Updating list items (list_name[index] = new_value)
    • Adding list items using:
      • append
      • extend
      • insert
      • +
    • Removing list items using:
      • pop
      • remove
      • del
    • Using additional list methods:
      • sort
      • reverse