Question

In: Computer Science

Write a Python program that creates a class which represents a Student Grade. The class includes...

Write a Python program that creates a class which represents a Student Grade. The class includes a function that reads a text file called Course_Score.txt. A sample of the file is provided below. Each row in the file corresponds to the Last Name, First Name, ClassWork score (100), Mid-Term score (100), and Final-Exam score (100). Also include the the following functions to process the content read from the file. a. getData(): This method reads the data from a file and stores the data as a list. b. grade(): This method calculates total score, percentage and grade for each student. A grade (above 90%), B grade (above 80%), C grade (above 60%), D grade (above 50%), and F grade (below 50%) c. highestTotal() and lowestTotal(): These methods calculate highest and lowest total scores in class.

Sample input file: Course_Score.txt

Naji Hasan 90 85 87

Lisa Smith 80 67 70

Andy Malik 75 80 52

Ravi Gupta 90 95 98

Dave Blair 50 61 70

Sara Clark 70 65 81

Sami Moosa 55 50 71

Imed Radhi 90 83 89

Kira Sunny 65 70 69

Hind Ahmed 70 81 88

Solutions

Expert Solution

SOLUTION-
I have solve the problem in python code with comments and screenshot for easy understanding :)

CODE-

main.py

#python code
#class
class studentGrades:
    # to read the file
    def __init__(self):
        self.file=open('Course_Score.txt','r')
        self.data=[]
        self.grades=[]
        self.totals=[]
    #gets data from file   
    def getData(self):
        for line in self.file.readlines():
            self.data.append(line.rstrip().split())
        self.file.close()
        return (self.data)
          
    def grade(self):
        #loop to gives the grades to students
        for d in self.data:
            self.Fname,self.Lname,*self.scores = d
            self.totalScore = int(self.scores[0])+\
            int(self.scores[1])+int(self.scores[2])
            self.totals.append(self.totalScore)
            self.percent = round(self.totalScore/3)
            if self.percent>=90:
                self.grade='A'
            elif self.percent>=80:
                self.grade='B'
            elif self.percent>=60:
                self.grade='C'
            elif self.percent>=50:
                self.grade='D'
            elif self.percent<=50:
                self.grade='F'
            self.grades.append((self.Fname+' '+self.Lname,self.totalScore,self.percent,self.grade))
            #prints the name , total , nPercentage ,grades
            print('Name: {0}\nTotal Score: {1}\nPercentage: {2}\nGrade: {3}\n'\
            .format(self.Fname+' '+self.Lname,self.totalScore,self.percent,self.grade))
    #for highest
    def highestTotal(self):
        return max(self.totals)
    #for lowest
    def lowestTotal(self):
        return min(self.totals)
#initalize
Grades = studentGrades()
data = Grades.getData()
#print data
print(data)
print()
#call functions
Grades.grade()
highTotal = Grades.highestTotal()
lowTotal = Grades.lowestTotal()
#print high and low
print('The highest total score is {}'.format(highTotal))
print('The lowest total score is {}'.format(lowTotal))

Course_Score.txt

Naji Hasan 90 85 87
Lisa Smith 80 67 70
Andy Malik 75 80 52
Ravi Gupta 90 95 98
Dave Blair 50 61 70
Sara Clark 70 65 81
Sami Moosa 55 50 71
Imed Radhi 90 83 89
Kira Sunny 65 70 69
Hind Ahmed 70 81 88

SCREENSHOT-

Course_Score.txt

IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------


Related Solutions

***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The...
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The program should allow creation an array of object instances to assign firstName, lastName and mark from input user and perform and assign grade based on mark’s criteria displayed below. MARKS INTERVAL 95 - 100 90 - <95 85 - <90 80 - <85 75 - <80 70 - <75 65 - <70 60 - <65 0 - <60 LETTER GRADE A+ A B+ B...
Write a C program that prints the Grade of each student in a class based on...
Write a C program that prints the Grade of each student in a class based on their mark. The program must also print the average mark of the class. The program must prompt (ask) the user for the mark of a student (out of 100). The program must then print the mark entered and the grade received based on the table below. Grade Range A 85 to 100 inclusive B 75 to 85 inclusive C 60 to 70 inclusive D...
Write a C++ program that creates a base class called Vehicle that includes two pieces of...
Write a C++ program that creates a base class called Vehicle that includes two pieces of information as data members, namely: wheels (type int) weight (type float) Program requirements (Vehicle class): Provide set and a get member functions for each data member. Your class should have a constructor with two parameters (one for each data member) and it must use the set member functions to initialize the two data members. Provide a pure virtual member function by the name displayData()...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
for Python 3 Write a python program that Creates a list that has these values in...
for Python 3 Write a python program that Creates a list that has these values in this order, 'Python', 'JavaScript', and 'PHP' Define a displayMyClasses function that sorts the list and then displays each item on the list, one per line, in sorted order. Also, number the displayed list as shown in the "Running a Sample Program" shown below. Define a guessNext function that selects a random element from the list and returns it to the call of the function....
Program 5A: Determine which student has the highest grade Write a Java program that determines which...
Program 5A: Determine which student has the highest grade Write a Java program that determines which student has the highest grade. You will ask the user to enter the number of students. Then you will ask for each student and their grade. You will output the name and grade of the student with the highest grade. You will NOT use an array for this assignment. Call your class Program5A, so your filename will be Program5A.java. It is essential for grading...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else statement logic​​​​​​​​​ b)​Write a Matlab program for sensor selection of temperature, pressure, flow sensor with if-else statement logic​​​​​​​​​ ​ 2.​Assume there are four letters from an information source with probabilities as A1 0.5 A2 0.3 A3 0.1 A4 0.1 Generate the tag and find the corresponding gaps and binary values for each stage and the sequence of the symbols which are coded are a1a3a2a4a1.​​​...
Create a class called Student which stores • the name of the student • the grade...
Create a class called Student which stores • the name of the student • the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into the grade field. • Calculate the...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade...
Lab 3.4 Write a program that determines a student’s grade. The student will enter a grade and the program will determine if that grade is an A, B, C, D, or E. The student can only enter number 0-100. A = 90-100 B = 80-89 C = 70-79 D= 60-69 E = 59 or less Save the file as Lab3.4 and submit the file. Use https://repl.it/ THIS LANGUAGE IS PYTHON Thank you :)
Write a program that creates a Singleton class to connect to two databases. The program must...
Write a program that creates a Singleton class to connect to two databases. The program must provide two instances of this class. One instance for connecting to MySQL database and the other for connecting to Oracle database.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT