Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ What is this repository about
This repository created as a tooltip for my students from ITEA.
Some homeworks are described here.

Added something new.
69 changes: 69 additions & 0 deletions class-Human.py
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 = ""

Copy link
Copy Markdown
Owner

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.

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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:

"List of `Student`'s marks."


def __init__(self):
print('Object of class "Student" is created')
super().__init__()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't make any sense.
Please use a super method properly.


def get_average_mark(self):
sum = 0
for mark in self.marks:
sum += mark

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong variable name.

It looks much easier:
return sum(self.marks)/float(len(self.marks))

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')