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

Python: Write a Student class that stores information for a student. The class s

ID: 3858477 • Letter: P

Question

Python: Write a Student class that stores information for a student. The class should include the following instance variables:

o id, an integer identifier for the student

o lastName, a string for the student's last name

o credits, an integer representing the number of course-credits the student has earned

o courseLoad, an integer representing the current number of credits in progress

Write the following methods for your Student class:

o A constructor (__init__) that, given an id, and a name, creates a Student with those values and no course-credits and no course load.

o A registerCurrent method that sets the current course load. The course load must be positive and no greater than 4 credits, otherwise no change happens

o A withdraw method, which decreases the course load by one credit, but never goes below 0.

o A passedCourse method, which removes one course from the current course load and adds to the students overall course-credits.

o A createEmail method, which returns a string. The string should be an email address of the student's name combined with their ID and remainder of @school.edu. For example, a student with last name "Jone", and ID 31 should return "jone31@school.edu"

This is what I have so far

class Student:
def __init__(self, i_d, lastName):
self.id = i_d
self.lastName = lastName
self.credits = 0
self.courseLoad = 0

def registerCurrent(self):
courseLoad = 3

def withdraw(self):
if courseLoad

def passedCourse(self):

def createEmail(self):
return self.lastName + self.id + "@school.edu"

student = Student(31, "Jone")
print(student.registerCurrent)
print(student.withdraw)
print(student.passedCourse)
print(Studen.createEmail)

Explanation / Answer

class Student:
def __init__(self, id, lastname):
self.id = id
self.lastname = lastname
self.courseload = 0
self.credits = 0
self.email = ''
  
def registerCurrent(self, courseload):
if courseload < 0 and courseload >4 :
self.courseload = 0;
else :
self.courseload = courseload
return self.courseload
  
def withdraw(self):
if self.courseload > 0 :
self.courseload = self.courseload -1
else :
self.courseload = 0
return selaf.courseload
  
def createEmail(self):
self.email = self.lastname + str(self.id)+ '@school.edu'
return self.email

student = Student(31, "Jone")
print(student.registerCurrent(3))
print(student.createEmail())