Docsity

CS 1301 Homework 6 - Python and Grading, Assignments of Computer Science

Toggle sidebar
bg1
Homework 6 CS 1301 – Fall 2006 Page 1/4
CS 1301 – Fall 2006
Homework 6 – Python and Grading
Due: Friday, October 13, 2006 at 6 PM EST
Files to submit: hw6.py
Functions to include in hw6.py:
• gradeBook(filename)
• computeStudentAverage(arr)
• sumCol(arr, col)
• averageCol(arr, col)
For Help:
Newsgroups – see course syllabus for more detailed information
TA Helpdesk – schedule will be posted on class website
Email TAs
Notes:
Think through the logic of each of the problems before you start coding anything
Don’t forget to include the required comments and collaboration statement (as outlined
on the course syllabus)
Retrieve your submission from WebWork and rerun it to be sure it still works okay
Do not wait until the last minute to do this assignment incase you run into problems
If you find an error in the homework assignment, let a TA know immediately
Information you might need:
Look at the Sequence types and file objects in the Python documentation here:
http://www.python.org/doc/2.4.1/lib/typesseq.html
http://www.faqs.org/docs/diveintopython/fileinfo_files.html
pf3
pf4

Partial preview of the text

Download CS 1301 Homework 6 - Python and Grading and more Assignments Computer Science in PDF only on Docsity!

CS 1301 – Fall 2006

Homework 6 – Python and Grading

Due: Friday, October 13, 2006 at 6 PM EST

Files to submit: hw6.py

Functions to include in hw6.py:

  • gradeBook(filename)
  • computeStudentAverage(arr)
  • sumCol(arr, col)
  • averageCol(arr, col)

For Help: ƒ Newsgroups – see course syllabus for more detailed information ƒ TA Helpdesk – schedule will be posted on class website ƒ Email TAs

Notes: ƒ Think through the logic of each of the problems before you start coding anything ƒ Don’t forget to include the required comments and collaboration statement (as outlined on the course syllabus) ƒ Retrieve your submission from WebWork and rerun it to be sure it still works okay ƒ Do not wait until the last minute to do this assignment incase you run into problems ƒ If you find an error in the homework assignment, let a TA know immediately

Information you might need:

Look at the Sequence types and file objects in the Python documentation here: http://www.python.org/doc/2.4.1/lib/typesseq.html http://www.faqs.org/docs/diveintopython/fileinfo_files.html

Background Story—

So here is the story, you have recently began tutoring students in computer science, and wanted to keep a record of your students’ progress in their class. You hate using spreadsheets with a passion so you have been keeping track of their grades in a text file (.txt) and you wanted to calculate averages and for each student and for all of your students. You figure since you are making good money, you might as well write up non-specific code that will take in a filename, open that file and do all the calculations. Remember you want to keep the code general – don’t hardcode the number of students in the file. Here is the sample text provided in grades.txt:

Amichai,85,60,99,100, Calvin,90,91,55,100, Alf,50,45,15,75,

Format: (name, hw1, hw2, hw3, test1, test2)

You may assume that you will only be given integer numbers for the grade!

Each row starts with a Name and is followed by 3 Homework grades and then 2 Test grades for the person named at the beginning of the row.

Each column (except for the Name column) is a specific Homework or Test grade. So 85, 90, and 45 are the grades needed to calculate for the HW1 average.

When we grade you homework, we will be using different input files that contain more student records. The format of the file, however, will remain the same. Do NOT hardcode the number of students.

Part 1 – sumCol(arr, col):

This should take in two parameters : a 2D array and a column number (integer). It should return the sum of the numbers in that column. Don’t forget to convert each item in your array into an integer. Do not print anything. Here is the sample output:

student = [["Aaron", "95", "100"], ["Josh", "35", "45"], ["Ami", "100", "100"]] sumCol(student, 1) 230 sumCol(student, 2) 245

HINT—Use a for loop to go through each row. Think about which variable needs to change (row or column) and which needs to stay the same (row or column)

NOTE: If you call in function in IDLE (not while running a saved file), it will automatically print what is returned by the function. The function itself does not print anything.

gradeBook("grades.txt") HW1 Average: 75. HW2 Average: 65. HW3 Average: 56. OVERALL HW Average: 65.

Test1 Average: 91. Test2 Average: 76. OVERALL TEST Average : 84.

Amichai's grade average is 85. Calvin's grade average is 88. Alf's grade average is 56. OVERALL CLASS AVERAGE: 76.

For extra credit make the output fancier. (No specifics here, surprise us!)

For even more extra credit, compute other statistics on the numbers:

  • Standard Deviation (http://illuminations.nctm.org/Lessons/States/FiveNumSum.htm)
  • 5 Number summary (http://illuminations.nctm.org/Lessons/States/FiveNumSum.htm)

Final thoughts

Be sure to name your file and functions exactly as indicated.

READ THROUGH THE INSTRUCTIONS CAREFULLY.

If you need help, be sure to come to office hours.

Good Luck!

Written by Amichai Israeli and Aaron Bozorg, Fall 2006.