Difference between revisions of "CSC111 Homework 4"

From dftwiki3
Jump to: navigation, search
(Submission)
(Recommendations)
Line 75: Line 75:
 
And continue from there, thinking of how you can modify what you have to make it deal with a variable number of grades, depending on how many the users wants to enter.
 
And continue from there, thinking of how you can modify what you have to make it deal with a variable number of grades, depending on how many the users wants to enter.
  
 +
===Testing===
 +
 +
Make sure you test your program with ''extreme'' cases.  For example, your program should work correctly if the user enters 0 for the number of homework assignments, in which case it will not ask for homework grades and will skip directly to the exam grades.
  
 
===Submission===
 
===Submission===

Revision as of 15:24, 17 February 2010

This assignment can be done in pair-programming mode, or individually. It is due on 2/25/2010 at midnight



Problem #1

Write a Python program called hw4a.py which computes the final grade for a student taking CSC111. The best way to understand how your program will work is to follow the example below where the user input is underlined:

python hw4a.py 
Welcome to the 111c grading center
==================================

How many homework assignments this semester? 10
What is the overall weight of the homework assignments? 0.60
What is the weight of the midterm exam? 0.20
What is the weight of the final exam?   0.20

Please enter the grades for the homework assignments, one per line,

4
4
3.3
3.7
4
3
3.3
3.7
4
4

Please enter the grades for the midterm, followed by the final, also one per line.

3.3
3.7


Number of assignments:     10
grade of lowest assignment                : 3
Sum of all the assignment (without lowest): 34.0
Average assignment grade (without lowest) : 3.77777777778

Weighted total average  = 3.66666666667


Requirements

Your program should prompt the user for the information in the same order shown in the example. Failure to follow the same order exactly will prevent your program from being tested correctly.

Your program should output the same information as shown in the example. This will include the number of assignments, the lowest assignment grade (more on this later), the sum and the average of the assignment grades, and the final grade.

Feel free to output the information in as user-friendly a format as you wish it to be!

Finding the smallest element in a sequence

To find the smallest element of a sequence of numbers, you can use the min() function. Run python in interactive mode, and try the following commands to understand how min() works.

>>>  a = [ 3, 10, 23, 1, 39 ]

>>>  min( a )

So, you can use min() to find the smallest of a sequence of grades.

Recommendations

Put all your python statements inside a main() function, and make sure you call main() at the end of your python program. Start small! Just start with a program that gets a fixed number of hw assignments, say 5. Make it compute the average of this series and display it. Then figure out how to find the smallest grade and print it And continue from there, thinking of how you can modify what you have to make it deal with a variable number of grades, depending on how many the users wants to enter.

Testing

Make sure you test your program with extreme cases. For example, your program should work correctly if the user enters 0 for the number of homework assignments, in which case it will not ask for homework grades and will skip directly to the exam grades.

Submission

Submit your program as follows:

      submit hw4  hw4a.py

Problem #2

In the works...