Question

In: Computer Science

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 students in the class.

Write the following functions in the program:

calc_average - this function should accept 8 assignment scores as arguments and return the average of the scores

determine_grade - this function should accept an assignment score 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

Data for the program:

Lucy Miller 45 69 70 66 87 82 75 73

Frank Jones         90 93 87 84 91 93 90 88

Nancy Franklin     99 97 92 90 88 89 87 90

Judy Forsyth        72 86 59 69 72 78 80 82

Tony Spirit           87 83 86 90 79 76 80 88

Ruth Ames           66 69 72 61 69 73 71 70

John Smith         100 98 89 93 82 86 91 93

Andrew Barnes    78 77 75 83 80 87 80 78

Becky Stone        98 94 90 89 84 83 79 93

Marvin Decker     59 54 61 45 39 66 70 72

Steve Parker       71 78 73 62 66 72 64 70

Frank Harper       89 86 90 92 91 85 88 93

Solutions

Expert Solution

CODE:

#function to get the grade
def determine_grade(marks):
#calculating the average marks of the list of marks
avg = int(sum(marks)/len(marks))
#returning the respective average
if(avg in range(90,101)):
return 'A'
elif(avg in range(80,90)):
return 'B'
elif(avg in range(70,80)):
return 'C'
elif(avg in range(60,70)):
return 'D'
else:
return 'F'
#function to calculate the average of list of marks
def calc_average(marks):
return sum(marks)/len(marks)
#list of students
listStudents = []
for i in range(12):
#dictionary which stores the data of each student
students = {'name':'','marks': [0]*8,'grade':'','average':0.0}
#asking for the name
students['name'] = input('Enter the name: ')
marks = ''
#asking for 8 marks in a single line
while(True):
marks = input('Enter marks of 8 subjects separated by a space: ')
if(len(marks.split(' ')) == 8):
break
print('8 marks expected! Try Again')
#determining the grade and the average marks
students['marks'] = [int(x) for x in marks.split(' ')]
students['grade'] = determine_grade(students['marks'])
students['average'] = calc_average(students['marks'])
#appending the student to the list
listStudents.append(students)
#displaying the results
print('\nStudents Details: ')
for i in listStudents:
print('Name: {}; Grade: {}; Average: {}'.format(i['name'],
i['grade'],
str(i['average'])))

________________________________________

CODE IMAGES:

_____________________________________________

OUTPUT:

____________________________________________________
Feel free to ask any questions in the comments section
Thank You!


Related Solutions

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 -...
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...
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]:...
Write a python program which asks the user to enter a positive number that is greater...
Write a python program which asks the user to enter a positive number that is greater than 30 called, “num2” and then does the following: o 1) Print all numbers between 1 and “num2” that are divisible by 2 and 3. o 2) Print all numbers between 1 and “num2” that are either divisible by 6 or 7. o 3) Print all numbers between 1 and “num3” that is not divisible by 5
Write a program that asks the user to enter an array of 8 characters then you...
Write a program that asks the user to enter an array of 8 characters then you have to check if characters ‘b’ or ‘a’ appears within the characters and replace them with ‘B’ or ‘A’. For example you enter “a m a l a a b d” The output should be “A m A l A A B d”
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT