Grade AnalyzerYou have a class consisting of 5 students, each with a unique name and their respective marks. As the end of the semester approaches, you decide to assess the performance of your students and recognize their academic achievements.You write a Python program to categorize the students into different grades based on their marks. The program utilizes a Grade_analyzer class to represent each student and a StudentGradeAnalyzer function to analyze their grades. The function iterates through the list of students, calculates their grades and returns a dictionary containing the count of students in each grade.For grading:Students scoring between 80-100 will be in Grade A.Students scoring between 70-80 will be in Grade B.Students scoring between 60-70 will be in Grade C.Students scoring between 50-60 will be in Grade D.Students scoring below 50 will be in Grade E.Constraints:Input Format:5 lines of input, each line containing name and marks of each student.Ouptut Format:Should display items in dictionary which is holding Grades as keys and count of students falling under the grades as values.Example:Input:john 78missy 89sheldon 90mary 45meemaw 67Output:('A', 2)('B', 1)('C', 1)('D', 0)('E', 1)Explanation:input:--------Space saperated input name and marks for all the 5 students.john 78-->78 Falls into a range 70-80 so count of grade 'B' should be increased to 1.missy 89-->89 Falls into a range 80-100 so count of grade 'A' should be increased to 1.sheldon 90-->90 Falls into a range 80-100 so count of grade 'A' should be increased to 2.mary 45-->45 is less than 50 so count of grade 'E' should be increased to 1.meemaw 67-->67 Falls into a range 60-70 so count of grade 'C' should be increased to 1.Output:--------Output should a dict which will hold how many students are falling into each grade.{'A': 2, 'B': 1, 'C': 1, 'D': 0, 'E': 1}Output will be printing each item in dict as a tuple. Public Test Cases:# INPUT EXPECTED OUTPUT1 john 78missy 89sheldon 90mary 45meemaw 67('A', 2) ('B', 1) ('C', 1) ('D', 0) ('E', 1)
Question
Grade AnalyzerYou have a class consisting of 5 students, each with a unique name and their respective marks. As the end of the semester approaches, you decide to assess the performance of your students and recognize their academic achievements.You write a Python program to categorize the students into different grades based on their marks. The program utilizes a Grade_analyzer class to represent each student and a StudentGradeAnalyzer function to analyze their grades. The function iterates through the list of students, calculates their grades and returns a dictionary containing the count of students in each grade.For grading:Students scoring between 80-100 will be in Grade A.Students scoring between 70-80 will be in Grade B.Students scoring between 60-70 will be in Grade C.Students scoring between 50-60 will be in Grade D.Students scoring below 50 will be in Grade E.Constraints:Input Format:5 lines of input, each line containing name and marks of each student.Ouptut Format:Should display items in dictionary which is holding Grades as keys and count of students falling under the grades as values.Example:Input:john 78missy 89sheldon 90mary 45meemaw 67Output:('A', 2)('B', 1)('C', 1)('D', 0)('E', 1)Explanation:input:--------Space saperated input name and marks for all the 5 students.john 78-->78 Falls into a range 70-80 so count of grade 'B' should be increased to 1.missy 89-->89 Falls into a range 80-100 so count of grade 'A' should be increased to 1.sheldon 90-->90 Falls into a range 80-100 so count of grade 'A' should be increased to 2.mary 45-->45 is less than 50 so count of grade 'E' should be increased to 1.meemaw 67-->67 Falls into a range 60-70 so count of grade 'C' should be increased to 1.Output:--------Output should a dict which will hold how many students are falling into each grade.{'A': 2, 'B': 1, 'C': 1, 'D': 0, 'E': 1}Output will be printing each item in dict as a tuple. Public Test Cases:# INPUT EXPECTED OUTPUT1 john 78missy 89sheldon 90mary 45meemaw 67('A', 2) ('B', 1) ('C', 1) ('D', 0) ('E', 1)
Solution 1
Here is a step-by-step solution to the problem:
- First, we need to create a class
Grade_analyzerto represent each student. This class will have two attributes:nameandmarks.
class Grade_analyzer:
def __init__(self, name, marks):
self.name = name
self.marks = marks
- Next, we need to create a function
StudentGradeAnalyzerto analyze the grades. This function will take a list ofGrade_analyzerobjects as input and return a dictionary with the count of students in each grade.
def StudentGradeAnalyzer(students):
grades = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0}
for student in students:
if 80 <= student.marks <= 100:
grades['A'] += 1
elif 70 <= student.marks < 80:
grades['B'] += 1
elif 60 <= student.marks < 70:
grades['C'] += 1
elif 50 <= student.marks < 60:
grades['D'] += 1
else:
grades['E'] += 1
return grades
- Now, we can create a list of
Grade_analyzerobjects and pass it to theStudentGradeAnalyzerfunction.
students = [Grade_analyzer('john', 78), Grade_analyzer('missy', 89), Grade_analyzer('sheldon', 90), Grade_analyzer('mary', 45), Grade_analyzer('meemaw', 67)]
grades = StudentGradeAnalyzer(students)
- Finally, we can print the output in the required format.
for grade, count in grades.items():
print((grade, count))
This will output:
('A', 2)
('B', 1)
('C', 1)
('D', 0)
('E', 1)
This is the complete solution to the problem.
Solution 2
Here is a Python solution for the problem:
class Grade_analyzer:
def __init__(self, name, marks):
self.name = name
self.marks = marks
def StudentGradeAnalyzer(students):
grades = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0}
for student in students:
if 80 <= student.marks <= 100:
grades['A'] += 1
elif 70 <= student.marks < 80:
grades['B'] += 1
elif 60 <= student.marks < 70:
grades['C'] += 1
elif 50 <= student.marks < 60:
grades['D'] += 1
else:
grades['E'] += 1
return grades
students = [Grade_analyzer('john', 78), Grade_analyzer('missy', 89), Grade_analyzer('sheldon', 90), Grade_analyzer('mary', 45), Grade_analyzer('meemaw', 67)]
grades = StudentGradeAnalyzer(students)
for grade, count in grades.items():
print((grade, count))
This program first defines a Grade_analyzer class to represent each student, with attributes for their name and marks. Then it defines a StudentGradeAnalyzer function to analyze the grades of a list of students. This function initializes a dictionary to keep track of the count of students in each grade, then iterates through the list of students, incrementing the appropriate grade count based on each student's marks. Finally, it returns the dictionary of grade counts.
The program then creates a list of Grade_analyzer objects representing the students, and passes this list to the StudentGradeAnalyzer function. The resulting dictionary of grade counts is then printed out, with each grade and count printed as a tuple.
Similar Questions
As a python student, write a program using functions and conditions to display the grades that the students will be receiving. The grades are:90% - 100% Grade is A 80% - 89% Grade is B70% - 79% Grade is C 60% - 69% Grade is D 50% - 59% Grade is E <50% Fail
.Write a Python program to store marks scored in subject “Fundamental of DataStructure” by N students in the class and perform different operations.
1. UTAMU University has tasked you to automate a simple grading system. As a python student, write a program using functions and conditions to display the grades that the students will be receiving. The grades are:90% - 100% Grade is A 80% - 89% Grade is B70% - 79% Grade is C 60% - 69% Grade is D 50% - 59% Grade is E <50% Fail
Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F
Writing a program using 'from' keyword along with importing asterisk (*).Write a program to calculates sum, average and final grade of a student using * in import.import all the functions from Module_Imp3.py using *.Taken the scores of a student as input from user.Calculate the sum of scores using the calculate_sum function by passing scores as argument.Calculate the average of scores using the calculate_average function by passing scores as argument.Determine the final grade based on the average score using the determine_grade function.Note: The Module_Imp3.py already is written. Just follow the above instructions and complete the program.Sample Test CasesTest Case 1:Expected Output:Enter·the·scores·separated·by·spaces:·90 85 70 60 75Sum·of·scores:·380.00Average·score:·76.00Final·grade:·CTest Case 2:Expected Output:Enter·the·scores·separated·by·spaces:·85.5 76.5 90.0 82.0 95.5Sum·of·scores:·429.50Average·score:·85.90Final·grade:·B
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.