Difference between revisions of "Module 4"

From CSE330 Wiki
Jump to navigationJump to search
(Creating from content formerly in Module 5)
 
Line 19: Line 19:
 
*# Finally, the script should take one optional command line argument, which is a string to match against student names.  Only names that match the string in full or in part, should be printed out with their final grades.
 
*# Finally, the script should take one optional command line argument, which is a string to match against student names.  Only names that match the string in full or in part, should be printed out with their final grades.
 
*#*For example, with the argument 'John' grades for both John Smith and John Locke should be printed (if those are the only two Johns in the grades.txt file)
 
*#*For example, with the argument 'John' grades for both John Smith and John Locke should be printed (if those are the only two Johns in the grades.txt file)
 +
 +
[[Category:Module 4]]
 +
[[Category:Modules]]

Revision as of 07:52, 8 April 2013

Install Python Tools

  • sudo yum install python-setuptools
  • sudo yum install python-devel

Python Assignment

  • You will write a python script that reads a set of student grades in from a file and does some basic parsing and processing. here is the section of the python tutorial on reading and writing files.
  • An example grades file is here. For the sake of simplicity you can assume that the file name is always going to be grades.txt.
  • The first line of the file is of the form: NUM_LABS,NUM_EXAMS,LAB_WEIGHT
  • All of the other lines in the file are of the form: FIRSTNAME LASTNAME|GRADE|TYPE
  • The FIRSTNAME and LASTNAME fields are the student's full name (always only a first and last name), the GRADE is one grade for the student, and the TYPE describes what kind of assignment the grade was for, in this case either a 'lab' or an 'exam'.
  • Your script should read in a grades file with the above format and perform the following:
    1. Compute the final grade for every student, given that there were a total of NUM_LABS labs, NUM_EXAMS exams, and that the labs account for a total of LAB_WEIGHT percent of the grade.
    2. Compute the final letter grade based on the final numeric grade (A = 90 or above, B = 80 - 90, C = 70 - 80, D = 60 - 70, F = below 60). 
    3. Ignore any blank lines.
    4. Sort the students by last name, and print out final grades in that sorted order.
    5. No names should be hard coded into the script (you will run your script on another file with different student names when we grade your assignment).
    6. Finally, the script should take one optional command line argument, which is a string to match against student names.  Only names that match the string in full or in part, should be printed out with their final grades.
      • For example, with the argument 'John' grades for both John Smith and John Locke should be printed (if those are the only two Johns in the grades.txt file)