-
Notifications
You must be signed in to change notification settings - Fork 1
/
23.py
42 lines (34 loc) · 1.01 KB
/
23.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Student:
def __init__(self, name, dept, marks):
self.name = name
self.dept = dept
self.marks = marks
def get_name(self):
return self.name
def get_Dept(self):
return self.dept
def get_marks(self):
return self.marks
def get_stu(self):
return "Name: " + self.name + ", Dept: " + self.dept + ", Marks: " + str(self.marks)
def __str__(self):
return "Name: " + self.name + ", Dept: " + self.dept + ", Marks: " + str(self.marks)
def __eq__(self, stu_obj):
if self.marks == stu_obj.marks:
return True
else:
return False
stu = Student('Satish', 'Computer', 25)
stu1 = Student('Mark', 'Computer', 25)
stu2 = Student('Steve', 'Computer', 29)
if stu == stu1:
print(stu.get_stu())
print(stu1.get_stu())
elif stu1 == stu2:
print(stu1.get_stu())
print(stu2.get_stu())
elif stu2 == stu:
print(stu.get_stu())
print(stu2.get_stu())
else:
print("No two students has same marks.")