Lab 11: File I/O | CMSC 105 Elementary Programming - Fall 2024

Lab 11: File I/O

Points Possible: 100

Due: Thursday, November 14th

In this lab, we will write programs using Python file input and output commands.

Use the File I/O guide for assistance.

Submission:

  1. Submit a Python file for each of the programs.

Program 1: Word Counter

Write a program word_counter.py that reads from a text file, counts the number of words in the file, and outputs the count to the console.

Sample Output:

Word count: 46

Save the program as word_counter.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Headers and comments: 5 points, file reading: 5 points, word count calculation: 10 points, output: 5 points)
Total: 25 points

Program 2: Uppercase Writer

Write a program uppercase_writer.py that reads from one file, converts its content to uppercase, and writes the uppercase text to a new file.

Sample Input (textfile.txt):

hello world  
this is a test file  

Sample Output (uppercase_output.txt):

HELLO WORLD  
THIS IS A TEST FILE  

Save the program as uppercase_writer.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Headers and comments: 5 points, file reading: 5 points, text transformation: 10 points, file writing: 5 points)
Total: 25 points

Program 3: Grade Average Calculator

Write a program grade_calculator.py that reads a list of grades from a file, calculates the average grade, and appends the average to the end of the file.

Sample Input (grades.txt):

85  
90  
78  
92  
88  

Sample Output (grades.txt after running the program):

85  
90  
78  
92  
88  
Average: 86.6

Save the program as grade_calculator.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Headers and comments: 5 points, file reading: 5 points, average calculation: 10 points, file writing/appending: 5 points)
Total: 25 points

Program 4: Student Grades Report

Write a program student_grades_report.py that reads student grades from a file, processes each student’s grades, and writes a report with the highest, lowest, and average grades for each student to a new file.

Save the program as student_grades_report.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Headers and comments: 5 points, file reading: 5 points, data processing: 15 points, file writing: 5 points)
Total: 25 points