2/3/2021 Python for O&G Lecture 81: OOP - Inheritance Part 1 - Colaboratory
Python for Oil and Gas
Website - [Link]
LinkedIn - [Link]
YouTube - [Link]
Inheritance
class Reservoir:
def __init__(self, av_por, av_perm, location):
[Link] = av_por
[Link] = av_perm
[Link] = location
def describe(self):
Saved successfully!
print(f"Porosity: {[Link]} and Permeability: {[Link]} md")
def situated(self):
/
print(f"This reservoir is located in {[Link]}.")
2/3/2021 Python for O&G Lecture 81: OOP - Inheritance Part 1 - Colaboratory
print(f This reservoir is located in {[Link]}. )
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):
[Link] = av_por
[Link] = av_perm
[Link] = location
[Link] = stimul
def describe(self):
print(f"Porosity: {[Link]} and Permeability: {[Link]} md")
def situated(self):
print(f"This reservoir is located in {[Link]}.")
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!