Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In PYTHON Write a class that represent an individual student. The class needs to

ID: 3676409 • Letter: I

Question

In PYTHON Write a class that represent an individual student. The class needs to have the following instance variables:

a unique id

a name in the form "smith, john"

two exam scores representing a midterm and an final

Your class will need a constructor to create each student so the user can enter the student ID, name, and exam scores. The class will also need the following methods.

a method to calculate the letter grade for the student based on the average of the exam scores. Use the grading scale used for this class.

a method to return the name, two exam scores, and the letter grade for a student.

You'll need a dictionary that will represent a particular course, like CIT101 for example. We'll add student instances to this dictionary so that the dictionary will hold the information for that course.

Each student instance will be held in the dictionary using the student ID as a key. Assume the dictionary is called CIT101, and the class is called Student, so calling
    Student(id, name, midterm, final)
creates an instance of the student class. Then if we were hardcoding all this it might look like the following.

CIT101 = {}        # create the containing dictionary
# add student instance to CIT101 dictionary
CIT101["123"] = Student("123", "smith, john", 78, 86)

Your program needs to have a 5-option menu that should look very much like the following.

    while True:
        print("""
        Menu options. Choose a number
           1. Create a new course
           2. Display course data
           3. Display all students
           4. Add a student
           5. Display a particular student
           6. Delete a student
           7. Save and Exit

         """)

Explanation / Answer

import sys

sys.version

print ' Menu Options 1. Create a new course 2. Display course data 3. Display all students 4. Add a student 5. Display a particular student 6. Delete a student 7. Save and Exit '

ch = input("Choose a Number: ")

if ch == '1'

course();

elseif ch == '2'

dispCourse();

elseif ch == '3'

disp= input(" Enter student Id to display: ")

dispStudent(disp);

elseif ch =='4'

addStudent();

elseif ch == '5'

display();

elseif ch == '6'

del= input(" Enter student Id to delete: ")

delStudent(del);

elseif ch == '7'

sys.exit()

def course():

courseName= input("Enter Course Name: ")

courseId= input("Enter Course Id: ")

with open('course.txt','wb') as myfile;   

     myfile.write(courseName)

myfile.write(courseId)

return;

def dispcourse():

with open('course.txt','r') as myfile;   

     print myfile.read();   

return;

def addStudent():

   Name = input("Enter Student Name: ")

   id = input(" Enter Student Id: ")

   midterm = input(" Enter Midterm score : ")

   final = input(" Enter final score : ")

with open('student.txt','w') as a myfile;

   for line in myfile.read(): fields = ' '.join(line.split())

print fields

rows = map(int,fields) # converting tuple to integer

data.extend(rows)

myfile.writerow(Id)

myfile.writerow(Name)

   myfile.writerow(midterm)

   myfile.writerow(final)

return;

   def delStudent(delStu):

   myfile = open('student.txt','w')

Lines = myfile.readlines();

   for delStu in Lines

removeLine(myfile,delStu)

return;

def dispStudent(dispStu):

   myfile = open('student.txt','r')

Lines = myfile.readlines();

   for dispStu in Lines

print myfile.readline()

return;

def display():

   myfile = open('student.txt','r')

print myfile.read()

return;

     

course();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote