- #1
mathmari
Gold Member
MHB
- 5,049
- 7
Hey! :giggle:
Construct a class named Student which when initializing its objects has the following variables :
- first_name (string)
- last_name (string)
- email (string)
The class should also support the following functions implemented as functions (methods):
- set_id_number: set a registration number (string)
- set_email: set an email (string)
- set_dept: set the department to which the student belongs
- get_id_number: returns the student registration number
- get_email: returns the student's email
- get_dept: returns the department to which the student belongs I have done the following :
Is the initialization correct?
Are the methods set and get email correct?
How do construct the methods for id and department? Which information do we use for that?
:unsure:
Construct a class named Student which when initializing its objects has the following variables :
- first_name (string)
- last_name (string)
- email (string)
The class should also support the following functions implemented as functions (methods):
- set_id_number: set a registration number (string)
- set_email: set an email (string)
- set_dept: set the department to which the student belongs
- get_id_number: returns the student registration number
- get_email: returns the student's email
- get_dept: returns the department to which the student belongs I have done the following :
Code:
class Student :
def __init__(self, first_name, last_name, email):
self.first_name = first_name
self.last_name = last_name
self.email = email
def set_id_number(self) :
def set_email(self, email) :
self.email = email
def set_dept(self) :
def get_id_number(self) :
def get_email(self) :
print ("The email of the student is : " self.email)
def get_dept(self) :
Is the initialization correct?
Are the methods set and get email correct?
How do construct the methods for id and department? Which information do we use for that?
:unsure: