Please enable JavaScript to use CodeHS

Utah Introduction to Python 2

Description

In this lesson, students learn how to access characters in a string using indexing.

Objective

Students will be able to:

  • Provide two index values (positive and negative) for any character in a string
  • Access individual characters in a string using index values
Description

In this lesson, students learn how to access multiple characters in a string using slicing.

Objective

Students will be able to:

  • Access multiple characters in a string using slicing
  • Describe which characters will be included in a slice when two values, one value, or no values are used (ie: #:#, #:, :#, :)
Description

In this lesson, students learn how to split strings into a list of characters or a list of groups of characters using list and split. They will also learn how to combine list items into a string using join.

Objective

Students will be able to:

  • Use list to separate a string into a list of characters
  • Use split to separate a string into a list of words or groups of characters depending on the element provided for the split character
  • Combine a list of elements into a string using join
Description

In this lesson, students learn how to use four new methods, strip, replace, find, and count, to alter strings.

Objective

Students will be able to:

  • Use the strip method to remove leading and trailing whitespace from a string
  • Use the replace method to use a different character throughout a string
  • Use the find method to return the index value of the first location of a certain element in a string
  • Use the count method to return the number of times an element occurs in a string
Description

In this lesson, students learn how to loop over characters in a string and ways to update strings as they are looped over.

Objective

Students will be able to:

  • Use the in keyword to access characters in a string
  • Use the range keyword to access characters in a string
  • Describe ways to alter characters in a string as it is looped through
Description

In this project, students work with a partner to analyze a blog post about game 5 of the Stanley Cup Final in 2023. They will follow scaffolded steps and will learn about web scraping which they will be simulating in this project.

Objective

Students will be able to:

  • Describe ‘web scraping’
  • Synthesize concepts and skills they have learned up to this point
  • Gain additional experience programming with a partner
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:
    • Indexing strings (string_var[index])
    • Slicing strings (string_var[index:index], string_var[index:], string_var[:index], string_var[:])
    • Splitting a string into a list of letters (list(string_var))
    • Splitting a string into a list of words (string_var.split() or string_var.split(element))
    • Combining a list into a string (element.join(list_var))
    • Looping over a list
    • Using additional string methods:
      • strip
      • replace
      • find
      • count