write a program that asks the user to enter five test scores. the pogram should display a letter grade for each score and the average test score. write the following function in the program.
calc_average-this function should accept five test scores as a argument and return the average of the scores
determine_grade - this function should accept a test score as an argyment and return a letter grade for the score, based on the following grading.

score                        letter grade
90-100                              a
80-89                               b
70-79                           c
60-69                           d
below 60                        f

Print grades for all individual tests and for the average test score. You must calculate grades in a function that has the test scores passed to it, one at a time
Have an additional function that accepts the score. The score must be at least 0 and no more than 100. All scores must be validated in a separate function that has the scores passed to it, one at a time.
The program should print out 4.0 instead of an “A”, 3.0 instead of a “B”, 2.0 instead of a “C”, 1.0 instead of a “D” and 0.0 instead of an “F”

Recommended Answers

All 2 Replies

Sounds good excersise, good luck.

Hint ...

# using module bisect to determine grades

import bisect

# both sequences have to be sorted or be in order
# A is 85 or higher, B is 75 to 84 etc.
grades = "FEDCBA"
breakpoints = [30, 44, 66, 75, 85]

def grade(total):
    return grades[bisect.bisect(breakpoints, total)]

print grade(66)  # C
print grade(33)  # E
print grade(85)  # A
print grade(77)  # B
print grade(27)  # F
commented: Good thinking! +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.