2/3/2021 Python for O&G Lecture 81: OOP - Inheritance Part 1 - Colaboratory
Python for Oil and Gas
Website - https://petroleumfromscratchin.wordpress.com/
LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch
YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw
Inheritance
class Reservoir:
def __init__(self, av_por, av_perm, location):
self.porosity = av_por
self.permeability = av_perm
self.location = location
def describe(self):
Saved successfully!
print(f"Porosity: {self.porosity} and Permeability: {self.permeability} md")
def situated(self):
/
print(f"This reservoir is located in {self.location}.")
2/3/2021 Python for O&G Lecture 81: OOP - Inheritance Part 1 - Colaboratory
print(f This reservoir is located in {self.location}. )
res_a = Reservoir(0.24, 85, 'Rajasthan')
res_a.describe()
Porosity: 0.24 and Permeability: 85 md
res_a.situated()
This reservoir is located in Rajasthan.
class Tight_reservoir:
def __init__(self, av_por, av_perm, location, stimul):
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}.")
res_b = Tight_reservoir(0.10, 10, 'Andhra Pradesh', 'Hydraulic Fracturing')
res_b.situated()
This reservoir is located in Andhra Pradesh.
# With the help of inheritence,
# Saved
whilesuccessfully!
making Tight_Reservoir class we'll just write extra attributes in this class and all other attributes that are in Reservoir class
# Reservoir is our base class or Parent Class /
2/3/2021 Python for O&G Lecture 81: OOP - Inheritance Part 1 - Colaboratory
# Tight Reservoir is our derived class or Child class
Saved successfully!