class Patient(object):
'''
Attributes
name = Patient name
age = Patient age
conditions = Existing patient's conditions
'''
status='patient'#-----------class variable-------
def __init__(self,name,age):
self.name=name
self.age=age
self.conditions=[]
def get_details(self):
print(f'Patient record: {self.name}, {self.age} years.'\
f'Current information: {self.conditions}.')
def add_info(self,information):
self.conditions.append(information)
x=Patient('Yash',21)
y=Patient('Raj',19)
class Infant(Patient):
def __init__(self,name,age):
self.vaccinations=[]
super().__init__(self,name,age)
def add_vac(self,vaccine):
self.vaccinations.append(vaccine)
def get_details(self):
print(f'Patient record: {self.name}, {self.age} years.'\
f'Patient has had {self.vaccinations} vaccines.'\
f'Current information: {self.codition}.'\
f'\n{self.name} IS AN INFACT, HAS HE HAD ALL HIS CHEAKS?')
ash=Infant('Yash',21)
ash.add_vac('MMR')
print(ash.get_details())
Asked
Active
Viewed 386 times
-2

dspencer
- 4,297
- 4
- 22
- 43

yash bhise
- 3
- 1
-
2Please repeat the intro tour; focus on [MRE](https://stackoverflow.com/help/minimal-reproducible-example). – Prune Apr 14 '20 at 16:11
-
1Please add description as to what you're actually asking. – Yoel Nisanov Apr 14 '20 at 16:13
-
Don't pass `self` to `super().__init__()` – Mark Apr 14 '20 at 16:13
-
1Your immediate problem is exactly what the message tells you. Remember that `self` is an implied argument when you call a class method. – Prune Apr 14 '20 at 16:13
-
You could try using: `super(Infant, self).__init__(name, age)` – garglblarg Apr 14 '20 at 16:43
-
Does this answer your question? [\_\_init\_\_() takes from 1 to 3 positional arguments but 4 were given](https://stackoverflow.com/questions/20209415/init-takes-from-1-to-3-positional-arguments-but-4-were-given) – Joe Apr 14 '20 at 17:20
1 Answers
0
class Patient(object):
'''
Attributes
name = Patient name
age = Patient age
conditions = Existing patient's conditions
'''
status='patient'#-----------class variable-------
def __init__(self,name,age):
self.name=name
self.age=age
self.conditions=[]
def get_details(self):
print(f'Patient record: {self.name}, {self.age} years.'\
f'Current information: {self.conditions}.')
def add_info(self,information):
self.conditions.append(information)
x=Patient('Yash',21)
y=Patient('Raj',19)
class Infant(Patient):
def __init__(self,name,age):
self.vaccinations=[]
super().__init__(name,age);
def add_vac(self,vaccine):
self.vaccinations.append(vaccine)
def get_details(self):
print(f'Patient record: {self.name}, {self.age} years.\
Patient has had {self.vaccinations} vaccines.\
Current information: {self.conditions}.\
{self.name} IS AN INFACT, HAS HE HAD ALL HIS CHEAKS?')
ash=Infant('Yash',21)
ash.add_vac('MMR')
print(ash.get_details())
this is only for ash instance ok, x, y is another instance.

A D
- 26
- 2
-
Please do not just code dump as an answer. Explain how this code answers the question and why. – Object object Apr 14 '20 at 18:47
-
so you don't need to pass the self parameter(in any class function super().__init__(self, name, age)), and second, you can not use f string format multiple times in single string(in get_details function). and you can find out your question's answer by comparing bothe programs – A D Apr 18 '20 at 09:05
-
Please read [answer] for more details on how to answer questions on SO – Object object Apr 18 '20 at 10:08