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

Write a Student class that stores information for a student. The class should in

ID: 3858506 • Letter: W

Question

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

oid, an integer identifier for the student

olastName, a string for the student's last name

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

ocourseLoad, an integer representing the current number of credits in progress

Write the following methods for your Student class:

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

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

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

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

oA 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 the code so far

class Student:
def __init__(self, i_d, lastName):
self.i_d = i_d
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 self.courseLoad

def passedCourse(self):
if self.courseLoad > 0:
self.courseLoad = self.courseLoad - 1
self.credits = self.credits + 1
return self.credits

def createEmail(self):
self.email = self.lastName + str(self.i_d)+ '@school.edu'
return self.email

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

The print statement returns

Jone31@school.edu

Explanation / Answer

There were two bugs in your code. I commented out on those two lines.please check out

class Student:
def __init__(self, i_d, lastName):
self.i_d = i_d
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_#courseload -> courseLoad
return self.courseLoad
def withdraw(self):
  
if self.courseLoad > 0:
  
self.courseLoad = self.courseLoad -1
else:
self.courseLoad = 0
  
return self.courseLoad #return was happening in else condition
def passedCourse(self):
if self.courseLoad > 0:
self.courseLoad = self.courseLoad - 1
self.credits = self.credits + 1
return self.credits
def createEmail(self):
self.email = self.lastName + str(self.i_d)+ '@school.edu'
return self.email
student = Student(31, "Jone")

print(student.registerCurrent(4))
print(student.withdraw())
print(student.passedCourse())
print(student.createEmail())

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