Question

In: Computer Science

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

Write a python program that asks the user to enter a student's name and 6 numeric tests scores (out of 100 for each test). The name will be a global variable. Create functions to calculate a letter grade for the student and calculate the average of the test scores for the student. The program should display a letter grade for each score, and the average test score, along with the student's name. Assume 6 students in the class.

Functions in the program:

the function should accept 6 test scores as arguments and return the average of the scores per student

the 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

Data for the program:

Jill Tree 70 66 87 82 75 73

Francis Ricks 90 93 87 84 91 93

Sally Smith 99 97 92 90 88 89

John Jones 72 86 59 69 72 78

Tommy Rimes    87 83 86 90 80 88

Erin Ames           66 69 72 61 73 71

Solutions

Expert Solution

Pseudo code:

  • Create global variable name to store name of the student.
  • Create method to calculate and return the average score of the student with 6 arguments as student scores.
  • Create method to find and return the grade for the average score of the student with average score as arguments.
  • Create main method to enter the name and scores of the student store it in a list.
  • Invoke method to calculate the average score of the student using for loop with scores of the student.
  • Invoke method to find grade of the student using for loop with average score of the student.
  • Please refer to the screenshots for the intendation of the program with sample output.

Program:

global name

stud=[]

def averageScore(score1, score2, score3, score4, score5, score6):
return (score1+score2+score3+score4+score5+score6)/6
  
def testGrade(score):
if(score>89 and score<101):
return 'A'
elif (score>79 and score <90):
return 'B'
elif (score>69 and score <80):
return 'C'
elif (score>59 and score <70):
return 'D'
return 'F'

def main():
for i in range(0,6):
name=input("Enter your student name "+str(i+1)+": ")
stud.append([name])
score=input("Enter your scores : ").split(" ")
stud[i]=stud[i]+[int(score[0])]
stud[i]=stud[i]+[int(score[1])]
stud[i]=stud[i]+[int(score[2])]
stud[i]=stud[i]+[int(score[3])]
stud[i]=stud[i]+[int(score[4])]
stud[i]=stud[i]+[int(score[5])]
  
average=[]
for x in stud:
score=averageScore(x[1], x[2], x[3], x[4], x[5], x[6])
average.append(score)
  
grade=[]
for x in average:
grade.append(testGrade(x))
  
for i in range(0,6):
print("Name : "+str(stud[i][0])+", Average : "+str(average[i])+", Grade : "+str(grade[i]))
  
if __name__== "__main__":
main()

Program Screenshot:

Sample Output:


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 -...
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...
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 -...
Python question Write a program that asks the user to enter a student's name and 8...
Python question Write a 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...
(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...
Write a Python program that asks the user to enter the monthly costs for the following...
Write a Python 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 Maintenance Write a function that takes these six items as arguments and computes the total cost of these expenses. Write a main program that asks the user for these six items and calls your function. Print total monthly cost and the total annual cost for these expenses. Your function should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT