camigirl4k3 0 Newbie Poster

A non-robot problem (Should be submitted independently). Write a Pyhton program, called Scores.py, which reads a collection of exam scores (integers) ranging from 1 to 100 and counts and prints the number of `A' scores, `B' scores, `C' scores, `D' scores and `F' scores based on the following grading scale: A: 90 to 100; B: 80 to 89, C: 70 to 79, D: 60 to 69 and F: 1 to 59. The program should also print the number of scores, the average score, the maximum score, and the minimum score. A sample run of the program is shown below:

>>> from Scores import *
>>> main()
Enter score (0 to stop): 63
Enter score (0 to stop): 75
Enter score (0 to stop): 72
Enter score (0 to stop): 72
Enter score (0 to stop): 78
Enter score (0 to stop): 67
Enter score (0 to stop): 80
Enter score (0 to stop): 63
Enter score (0 to stop): 75
Enter score (0 to stop): 90
Enter score (0 to stop): 89
Enter score (0 to stop): 43
Enter score (0 to stop): 59
Enter score (0 to stop): 99
Enter score (0 to stop): 82
Enter score (0 to stop): 12
Enter score (0 to stop): 100
Enter score (0 to stop): 0

Number of "A" scores = 3
Number of "B" scores = 3
Number of "C" scores = 5
Number of "D" scores = 3
Number of "F" scores = 3
-------------------------
Total Scores = 17

Average Score = 71.0
Maximum Score = 100
Minimum Score = 12

You must implement the solution in two functions: main() and computeAnswers(L). The main() function prompts the user for the scores (one at a time, until the user enters 0) and populates a list of score. The computeAnswers(L) function examines scores in the list one at a time and performs the necessary computations to calculate the answers. It then puts all the answers in a list and returns that list.

This is what I have so far..

(and sorry for not using the proper indentation last time. this time I'll make it easier for you, sumimasen)

def findAverage(L):
    sum = 0.0
    for x in L:
        sum = sum + x
        return sum/len(L)

def findLetterGrade(score):
            if score in range(90,101):
                return A
            elif score in range(80, 90):
                return B
            elif score in range(70, 80):
                return C
            elif score in range(60, 70):
                return D
            elif score in range(1, 59):
                return F
    

def countGrades(L):
    countA = 0
    countB = 0
    countC = 0
    countD = 0
    countF = 0
    for i in L:
        if L(i) == A:
            countA + 1 = countA
            return countA
        elif L(i) == B:
            countB + 1 = countB
            return countB
        elif L(i) == C:
            countC + 1 = countC
            return countC
        elif L(i) == D:
            countD + 1 = countD
            return countD
        elif L(i) == F:
            countF + 1 = countF
            return countF
# this is so not right but....this is what I have for compute answers.....I think I need to introduce some variables but I don't want to mess it up.

def computeAnswers(L):
    findLargest(L)
    findSmallest(L)
    findAverage(L)
    countGrades(totalGrades(L))

# please please help me! I'll give you cookies!!

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.