0% found this document useful (0 votes)
10 views3 pages

Python For Og Lecture 81 - Oop Inheritance Part 1

The document discusses inheritance in Python by defining a Reservoir class with attributes like porosity, permeability, and location. It then defines a Tight_reservoir class that inherits from Reservoir and adds a stimulation attribute. Objects are created from each class and their methods like describe() and situated() are called.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Python For Og Lecture 81 - Oop Inheritance Part 1

The document discusses inheritance in Python by defining a Reservoir class with attributes like porosity, permeability, and location. It then defines a Tight_reservoir class that inherits from Reservoir and adds a stimulation attribute. Objects are created from each class and their methods like describe() and situated() are called.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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!

You might also like