Question

In: Computer Science

USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program...

USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score.

Hint:

Declare local variables under main() program

Prompts the user to enter 5 test scores

Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg

Define a function to determine the letter grade: this should accept a test score as argument and return a letter grade based on the following grading scale.

Score         Letter Grades

90-100                A

80-89                   B

70-79                   C

60-69                   D

Below 60            F

Solutions

Expert Solution

def calc_average(n1,n2,n3,n4,n5):
    return (n1+n2+n3+n4+n5)/5

def determine_grade(score):
    if score < 60:
        letter = 'F'
    elif score < 70:
        letter = 'D'
    elif score < 80:
        letter = 'C'
    elif score < 90:
        letter = 'B'
    else:
        letter = 'A'
    return letter

def main():
    n1 = eval(input("Enter test score1: "))
    n2 = eval(input("Enter test score2: "))
    n3 = eval(input("Enter test score3: "))
    n4 = eval(input("Enter test score4: "))
    n5 = eval(input("Enter test score5: "))
    print("\nScore\tLetterGrade")
    print("------------------------")
    print(n1,"\t\t",determine_grade(n1))
    print(n2, "\t\t", determine_grade(n2))
    print(n3, "\t\t", determine_grade(n3))
    print(n4, "\t\t", determine_grade(n4))
    print(n5, "\t\t", determine_grade(n5))
    avg = calc_average(n1,n2,n3,n4,n5)
    print("\nAverage test score =",avg)

main()


Related Solutions

write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
Declare local variables under main() program Prompts the user to enter 5 test scores Define a...
Declare local variables under main() program Prompts the user to enter 5 test scores Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg Define a function to determine the letter grade: this should accept a test score as argument and return a letter grade based on the following grading scale. Score         Letter Grades 90-100                A 80-89                   B 70-79                   C 60-69                   D Below 60            F
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
Write a test program that prompts the user to enter a sequence of numbers ending with...
Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes this method to return the largest number in the input. Use inheritance and polymorphism approach. in java please
Write a JAVA program that prompts the user to enter a single name. Use a for...
Write a JAVA program that prompts the user to enter a single name. Use a for loop to determine if the name entered by the user contains at least 1 uppercase and 3 lowercase letters. If the name meets this policy, output that the name has been accepted. Otherwise, output that the name is invalid.
Write a Python program using functions and mainline logic which prompts the user to enter a...
Write a Python program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a file. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The average number in the list At a minimum, the numbers should...
Write a PYTHON program that prompts the user to enter the account’s present value, yearly interest...
Write a PYTHON program that prompts the user to enter the account’s present value, yearly interest rate, and the number of years that the money will be left in the account. The program should pass these values to a function that returns the future value of the account, after the specified number of months. The program should display the accounts’ future value
In PYTHON OF JUPIDER NOTEBOOK Write a program that prompts the user to enter his/her nationality...
In PYTHON OF JUPIDER NOTEBOOK Write a program that prompts the user to enter his/her nationality (French/french, Italian/italian, or Spanish/spanish). Then ask his/her name using a prompt message in his/her own language (use Google Translate if you need). After getting the name, again greet him/her using a greeting message in his/her own language. If the user is not from any of the above nationalities just use English to prompt for name and to greet the user. Example 1: Nationality? french...
( USE C++ ) The program prompts the user to enter a word. The program then...
( USE C++ ) The program prompts the user to enter a word. The program then prints out the word with letters in backward order. For example, if the user enter "hello" then the program would print "olleh" show that it works .
Use Java (Geometry: point in a rectangle?) Write a program that prompts the user to enter...
Use Java (Geometry: point in a rectangle?) Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5.  For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to10 / 2 and its vertical...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT