Python For Og Lecture 82 and 83 - Oop Inheritance Part 2 and 3
Python For Og Lecture 82 and 83 - Oop Inheritance Part 2 and 3
Website - https://petroleumfromscratchin.wordpress.com/
LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch
YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw
class Reservoir:
def __init__(self, av_por, av_perm, location):
self.porosity = av_por
self.permeability = av_perm
self.location = location
def describe(self):
print(f"Porosity: {self.porosity} and Permeability: {self.permeability} md")
def situated(self):
print(f"This reservoir is located in {self.location}.")
# class Tight_reservoir: /
2/3/2021 Python for O&G Lecture 82 and 83: Inheritance Part 2 and 3 - Colaboratory
# self.porosity = av_por
# self.permeability = av_perm
# self.location = location
# self.stimulation = stimul
# def describe(self):
# print(f"Porosity: {self.porosity} and Permeability: {self.permeability} md")
# def situated(self):
# print(f"This reservoir is located in {self.location}.")
# METHOD 1
class Tight_reservoir(Reservoir):
self.stimulation = stimul
res_a.location
/
2/3/2021 Python for O&G Lecture 82 and 83: Inheritance Part 2 and 3 - Colaboratory
'Assam'
res_a.describe()
# method 2
class Tight_reservoir(Reservoir):
def __init__(self, av_por, av_perm, location, stimul):
# Reservoir.__init__(self, av_por, av_perm, location)
super().__init__(av_por, av_perm, location)
self.stimulation = stimul
def stim_method(self):
return f'Stimulation method for this reservoir is {self.stimulation}'
res_d.stim_method()
/
2/3/2021 Python for O&G Lecture 82 and 83: Inheritance Part 2 and 3 - Colaboratory
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-24-45f39720ba47> in <module>()
3 res_d = Reservoir(0.12, 15, 'Assam')
4
----> 5 res_d.stim_method()
class Reservoir:
def __init__(self, av_por, av_perm, location):
self.porosity = av_por
self.permeability = av_perm
self.location = location
def describe(self):
print(f"Porosity: {self.porosity} and Permeability: {self.permeability} md")
def situated(self):
print(f"This reservoir is located in {self.location}.")
class Any_class(Reservoir):
def __init__(self, av_por, av_perm, location, pi, pb):
/
2/3/2021 Python for O&G Lecture 82 and 83: Inheritance Part 2 and 3 - Colaboratory
self.initial = pi
self.bubble = pb
def pressure(self):
return f'Initial pressure: {self.initial} psi and bubble point pressure: {self.bubble}'
a.pressure()
class Raj_res(Any_class):
self.water_sat = s_w
def sat(self):
return f'water saturation is {self.water_sat}'
b.describe()
# Reservoir - Grandfather
# Any_class - father
# Raj_res - child
/
2/3/2021 Python for O&G Lecture 82 and 83: Inheritance Part 2 and 3 - Colaboratory