Class Register

class-register

Learning Objectives


In this challenge we are going to focus on accessing a text file in Python to:

  • Read the content of the file line by line,
  • Write data to a new file.

Before completing this challenge, you should read about the main file handling operations using Python.

Your Challenge


Your challenge consists of writing a Python script that could be used by a teacher to take the register at the beginning of the lesson.

Your program will need to:

  1. Read the text file called classList.txt, line by line.
  2. For each student (line of the text file) the program should ask the teacher if the pupil is pesent (“/” code), absent for medical reasons or illness (“M” code), on a school trip (“T” code), or absent with no reason provided yet (“X” code).
  3. The program should store the teacher’s input alongside with the name of each pupil into a new text file called “register.txt”.

To complete this challenge you will need to use the class list text file:


TextFile
ClassList.txt

Python Code

Complete the Python code below…

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 2.2 / 5. Vote count: 13

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!