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

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!

You might also like