-
Notifications
You must be signed in to change notification settings - Fork 0
duchuy-new #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
duchuy-new #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # FIRST change for github | ||
|
|
||
|
|
||
| class Human: | ||
|
|
||
| def __init__(self): | ||
| print('The super class is "Human" ') | ||
| name = "" | ||
| surname = "" | ||
| age = 0 | ||
| gender = "" | ||
|
|
||
| def get_name(self): | ||
| return self.name | ||
| def get_surname(self): | ||
| return self.surname | ||
| def get_age(self): | ||
| return self.age | ||
| def get_gender(self): | ||
| return self.gender | ||
|
|
||
| class Student(Human): | ||
|
|
||
| marks = [] #list of student's marks | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comments before line you want to comment. Also, please use full sentences: |
||
|
|
||
| def __init__(self): | ||
| print('Object of class "Student" is created') | ||
| super().__init__() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't make any sense. |
||
|
|
||
| def get_average_mark(self): | ||
| sum = 0 | ||
| for mark in self.marks: | ||
| sum += mark | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong variable name. It looks much easier: |
||
| average_mark = sum/len(self.marks) | ||
| return average_mark | ||
|
|
||
| class Teacher(Human): | ||
|
|
||
| classes = 0 | ||
|
|
||
| def __init__(self): | ||
| print('Object of class "Teacher" is created') | ||
| super().__init__() | ||
|
|
||
| def get_number_of_classes(self): | ||
| return self.classes | ||
|
|
||
| # Student's instance: | ||
|
|
||
| student_1 = Student() | ||
| student_1.name = 'Igor' | ||
| print('Student_1\'s name is : ' ,student_1.get_name()) | ||
|
|
||
| student_1.marks.append(5) | ||
| student_1.marks.append(6) | ||
| student_1.marks.append(7) | ||
| print('Student_1\'s marks are : ',student_1.marks) | ||
| print('and his average mark is : ',student_1.get_average_mark()) | ||
| print() | ||
|
|
||
| # Teacher's instance: | ||
|
|
||
| teacher_1 = Teacher() | ||
| teacher_1.age= 35 | ||
| teacher_1.classes = 5 | ||
| print('teacher_1\'s age is : ' ,teacher_1.get_age()) | ||
| print('He has : ' ,teacher_1.get_number_of_classes(), 'classes') | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's much better to use constructor for this purpose.