Please enable JavaScript to use CodeHS

Utah Introduction to Python 2

Description

In this lesson, students learn how to write to existing files. They will explore two modes: “w” for overwriting a file and “a” for appending to a file.

Objective

Students will be able to:

  • Understand the purpose and importance of writing to files in programming
  • Use the “w” mode to overwrite the contents of a file
  • Use the “a” mode to append new data to the end of a file
Description

In this lesson, students learn how to manipulate the file pointer position using the seek() and tell() methods in Python. They will explore how seek() can be used to move the pointer to a specific location within a file, enabling operations at desired positions.

Objective

Students will be able to:

  • Understand the concept of a file pointer and its role in reading and writing data
  • Use the tell() method to return the location of the file pointer
  • Use the seek() method to move the file pointer to a specific position within a file
  • Perform reading operations at a desired file pointer position
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:
    • using write to create new files and append information to already existing files
    • using tell to return file pointer position
    • using seek to move the file pointer to a new position