EE 355 Lab 15 - Python Practice
1 Introduction
In this lab you will write a program in Python to read in student info from a file and
output the average of their scores.
This is a peer evaluated lab where your grade will be determined by 2 peer
evaluations. Please see the guidelines for peer evaluated labs provided by the
2 What you will learn
After completing this lab you should be able:
 Write and run a Python script
 Use a dictionary and list data structures in Python
 Use file I/O in Python
 Write a 'class' definition in Python
3 Background Information and Notes
Review the lecture slides on Python
4 Procedure
1. Create a file ''
2. At the top of the file (after your import's), create a student class that has a name
member and grades member (i.e. a list) as well as the following methods
a. Constructor takes in name argument
b. Create method to add a score
c. Create a method to average scores
3. Then after the class definition, write a script that will do the following…
4. Read student data in from a text file where each line contains a first name & last
name followed by some number of scores (Handle any number of students with
any number of scores after their name). The text file should be passed in as a
command line argument
5. Read in the names, concatenate first and last and create a new student object,
then read in each score and add it to the student object
6. Enter each student object into a dictionary (key = name, value = Student object)
7. When done reading, iterate through dictionary and compute average of each
students’ scores and output their name and average to the screen (separated by
a space)
8. Test your program with the following test input:
Last Revised: 3/17/2015
EE 355 Lab 15 - Python Practice
$ wget
$ wget
Sample Input:
Tommy Trojan 85 64 93
Jane Smith 99 93 86
9. You can run your program via:
$ python studata.txt
$ python studata2.txt
5 Evaluation Criteria
1. [5 pts.] Run the program and use the 'studata.txt" sample input above and verify
the output.
2. [5 pts.] Run the program and use the 'studata2.txt' and verify it outputs
appropriate values.
Last Revised: 3/17/2015