class Student:
def __init__(self):
pass
student1 = Student()
student1.first_name = "kanz"
student1.last_name = "kang"
student2 = Student()
student2.first_name = "hong"
student2.last_name = "kong"
print(student1.last_name)
print(student2.last_name)
class Student:
school = 'Online school'
number_of_students = 0
def __init__(self, first_name, last_name, major):
self.first_name = first_name
self.last_name = last_name
self.major = major
Student.number_of_students += 1
def fullname_with_major(self):
return f'{self.first_name} {self.last_name} is a {self.major} major!'
def fullname_major_school(self):
return f'{self.first_name} {self.last_name} is a ' \\
f'{self.major} going to {self.school}'
@classmethod
def set_online_school(cls, new_school):
cls.school = new_school
@classmethod
def split_students(cls, student_str):
first_name, last_name, major = student_str.split('.')
return cls(first_name, last_name, major)
print(f'number of student = {Student.number_of_students}')
student1 = Student('eric', 'roby', 'computer science')
student2 = Student('john', 'miller', 'math')
print(student1.fullname_major_school())
print(student2.fullname_major_school())
print(f'number of student = {Student.number_of_students}')
print(student1.school)
print(student2.school)
Student.set_online_school("test school")
print(student1.school)
print(student2.school)
new_student = 'Adil.tui.english'
student3 = Student.split_students(new_student)
print(student3.fullname_with_major())