-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython 48.py
More file actions
56 lines (35 loc) · 1.15 KB
/
Copy pathpython 48.py
File metadata and controls
56 lines (35 loc) · 1.15 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
87. With a given list [12, 24, 35, 24, 88, 120, 155, 88, 120, 155], write a program to print this list after removing all
duplicate values with original order reserved.
Hints: Use set() to store a number of values without duplicate.
# In[1]:
a=[12, 24, 35, 24, 88, 120, 155, 88, 120, 155]
b=[]
for i in a:
if i not in b:
b.append(i)
print(b)
# In[ ]:
88. Define a class Person and its two child classes: Male and Female. All classes have a method "getGender" which can
print "Male" for Male class and "Female" for Female class.
Hints: Use Subclass(Parentclass) to define a child class.
# In[4]:
class Person:
def getGender(self):
print('unknown')
class Male(Person):
def __init__(self,male):
self.male=male
def getGender(self):
return f'{self.male} is male'
class Female(Person):
def __init__(self,female):
self.female=female
def getGender(self):
return f'{self.female} is female'
obj1=Male('ram')
obj2=Female('sita')
print(obj1.getGender())
print(obj2.getGender())