# Assignment 4

due in class on Wed 9 Nov

For this assignment, you will write a small Python program. It should input 4 quiz grades, then drop the lowest one, and compute the average of the other 3. It should print the average and a letter grade, determined using the following table:

 ≥ 90 A ≥ 80 B ≥ 70 C ≥ 60 D otherwise F

Here is a sample run of the program. The scores on the first four lines are text that the user types.

``````    Enter quiz 1: 90
Enter quiz 2: 40
Enter quiz 3: 100
Enter quiz 4: 80
Dropped 40, average is 90, which is an A.
``````

Of course, it should work for any values that the user types.

There are a number of good ways to approach this. Edit your program in small stages, testing only a few new lines of code at a time. First you could enter the quizzes and print the sum of all of them. Then print the average. Then print a letter grade. Finally, find the lowest score. As a hint, you don’t really have to exclude the lowest from the sum. Instead, you can add all four, and then subtract the lowest later on. Make sure you test a variety of different inputs. Does it find the lowest, no matter which order scores are entered? What if two quizzes have the same score? As a reminder, here are some of the elements of python you will use:

• Input:

``quiz1 = float(raw_input("Enter quiz 1: "))``
• Variables and computation:

``sum = quiz1 + quiz2 + quiz3 + quiz4``
• Output:

``print "The average is", average``
• Conditions:

``if quiz1 < quiz2 and quiz1 < quiz 3:    lowest = quiz1if average >= 90:    print "Great!"else:    print "Oops!"``

©2011 Christopher League · some rights reserved · CC by-sa