Question

In: Computer Science

Write a Python program that asks the user to enter a student's name and 8 numeric...

Write a Python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student

determine_grade - This function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale: 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F

REMEMBER - to put your name on the lab in comments and put comments in your program for what the program is doing.

Don't forget the comments.

Solutions

Expert Solution

# function to determine grade
def determine_grade(score):
    if score >= 90:
        return 'A'
    elif score >= 80:
        return 'B'
    elif score >= 70:
        return 'C'
    elif score >= 60:
        return 'D'
    else:
        return 'F'


def calc_average(g1, g2, g3, g4, g5):
    # calculate the average of grades and return result
    return (g1 + g2 + g3 + g4 + g5) / 5.0


def main():
    # get score
    score1 = int(input("Enter a score: "))
    # determine and print grade
    print("Letter grade is " + determine_grade(score1))
    # get score
    score2 = int(input("Enter a score: "))
    # determine and print grade
    print("Letter grade is " + determine_grade(score2))
    # get score
    score3 = int(input("Enter a score: "))
    # determine and print grade
    print("Letter grade is " + determine_grade(score3))
    # get score
    score4 = int(input("Enter a score: "))
    # determine and print grade
    print("Letter grade is " + determine_grade(score4))
    # get score
    score5 = int(input("Enter a score: "))
    # determine and print grade
    print("Letter grade is " + determine_grade(score5))

    # find average of scores
    avg = calc_average(score1, score2, score3, score4, score5)
    # print average
    print("Average score is " + str(avg))
    print("Average grade is " + determine_grade(avg))  # find grade of average and print


if __name__ == '__main__':
    main()  # call main function

Related Solutions

PYTHON Write a program that asks the user to enter a student's name and 8 numeric...
PYTHON Write a program that asks the user to enter a student's name and 8 numeric assignment scores (out of 100 for each assignment). The program should output the student's name, a letter grade for each assignment score, and a cumulative average for all the assignments. Please note, there are 12 students in the class so your program will need to be able to either accept data for 12 students or loop 12 times in order to process all the...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or enter -1 to stop. When finished entering all the scores, the program should display the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. (IN PYTHON)
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Please write in Python code please: Write a program that asks the user to enter 5...
Please write in Python code please: Write a program that asks the user to enter 5 test scores between 0 and 100. The program should display a letter grade for each score and the average test score. You will need to write the following functions, including main: calc_average – The function should accept a list of 5 test scores as an input argument, and return the average of the scores determine_grade – The function should accept a test score as...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663. This is my code, but I cannot figure out where to go from here. #set new number new_number = "" #split number split_num = phone.split("-") for char in split_num[1:2]:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT