18 views2 pages
13 Jun 2018
School
Course
Professor
def email(self):
"""
-------------------------------------------------------
Generates and returns a compatible email address.
Use: email = student.email()
-------------------------------------------------------
Returns:
result - a email address of the form
-------------------------------------------------------
"""
result = self.login() + "@gmail.com"
return result
def write(self, fv):
"""
-------------------------------------------------------
Writes this student's attributes to an already open
comma-delimited file.
Use: student.write(fv)
-------------------------------------------------------
Parameters:
fv - a file variable, open for writing or appending (file)
Returns:
None
-------------------------------------------------------
"""
string = "{},{},{},{},{}".format(self.student_id, self.surname,
self.forename, self.gender,
self.birth_date)
print(string, file=fv)
return
The only way to create a Student object is to call the Student constructor and pass it the
proper parameters. The following string contains student data:
123456789,Cash,duke,M,1912-04-15
but this string is not a Student object.
If, however, we call the Student constructor and pass it this same data:
from Student import Student
some_student = Student("123456789", "Cash", "Duke", "M", "1912-04-15")
then the variable some_student is a Student object, because it was created by calling the
Student constructor.
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in