Graduation Announcements

For Lab 10, you will be given a file of student information in a known format. This means that each file is formatted the same, and that you know the format.

For this assignment, you are going to iterate through each item in the file, and write to a separate file what should be announced as they walk across the stage. This includes their name (first name, then last name), and their major.

You will also be looking for the student with the highest GPA (the valedictorian), and will print that out to the screen before your program exits (you do not need to write it to a file.) There will not be any "ties" for highest GPA in the file, so you do not need to worry about that.





Creating your program

Now you are going to write a Python program called graduation.py.

Once you are in your lab10 folder, open your file for editing by typing

       emacs graduation.py

The first thing you should do in your new file is create and fill out the comment header block at the top of your file. Here is a template (it is text, so feel free to copy and paste it into your file):

# File:        graduation.py
# Author:      YOUR NAME
# Date:        TODAY'S DATE
# Section:     YOUR SECTION NUMBER
# E-mail:      USERNAME@umbc.edu
# Description: YOUR DESCRIPTION GOES HERE AND HERE
#              YOUR DESCRIPTION CONTINUED SOME MORE
# Collaboration: During lab, collaboration between students is allowed,
#                although I understand I still must understand the material
#                and complete the assignment myself. 





Getting the roster.txt file

The file you are using is called roster.txt, and contains 25 different students. The format of the file is that each line contains a student's major, GPA, last name, and first name (in that order), separated by semicolons.

To download the file of student information, use the cp command. Don't forget the period at the end!

        cp /afs/umbc.edu/users/k/k/k38/pub/cs201/roster.txt .





Incremental development

You should be coding Lab 10 in an incremental manner. In other words, you should code up one piece of the lab and test that it works before moving on to the next piece. Incremental development is a very effective way of tackling a problem, in part because it is easier to figure out where an error occurs when you are only working on a small part of the code at a time.

We will not be breaking it down for you as done previously, but you could start by opening the file, reading in the file's contents, and ensuring that this works. Then move on to the rest of the lab.





Sample output

Here is some (partial) sample output for the file created with the graduation announcements. You might want to call it the announcements.txt file. The output to your file should be very similar, but does not have to be identical.

Brian Lewis is graduating with a degree in CHEM
Neville Owens is graduating with a degree in POLI
Luke Pugh is graduating with a degree in CMSC
Hiroko Garner is graduating with a degree in HIST
Sara Dixon is graduating with a degree in ENGL
Hermione Frank is graduating with a degree in IS
Garrison English is graduating with a degree in MECH
[etc]

Remember to enable Python 3 before running your program!





If you get stuck, there are hints for a number of common problems under the "Additional Help" link in the left hand menu. Try to complete the program on your own before turning to these hints.