Question
**PYTHON EXPERTS ONLY** PLS ENSWER PROBLEM 1 AND PROBLEM 2. (PLS CHECK YOUR ANSWERS BEFORE YOU POST THEM) - you may use the constant pi
**PYTHON EXPERTS ONLY**
PLS ENSWER PROBLEM 1 AND PROBLEM 2. (PLS CHECK YOUR ANSWERS BEFORE YOU POST THEM)
- you may use the constant pi in compute_wellbore_volume member functions.
PROBLEM 1
Below is a template implementation of a class Well. You should first implement the __str__ member function for Well such that it returns a string formated to read:
'Well type: '
where will later be replaced with a string that indicates the well type in derived classes (see examples below).
Next derive a class called VerticalWell from Well that has an attribute well_type = 'vertical' and takes a positional argument depth at instantiation and assigns it to an attribute called depth. Then implement a member function called compute_wellbore_volume that takes a positional argument diameter and using diameter and the attribute depth, computes the total volume of the wellbore. See the follow examples for the expected usage of the class and member functions. You should notreimplement the __str__ function in VerticalWell.
vertical_well = VerticalWell(depth = 5000) print(vertical_well)
will return
'Well type: vertical'
Also,
vertical_well.depth
will return
5000
and
vertical_well.compute_wellbore_volume(diameter = 0.5)
will return
981.7477042468104
I have imported the constant pi from the Python math module. You may use it in compute_wellbore_volume member functions.
In [10]:
from math import pi class Well(): def __init__(self): self.well_type = None
PROBLEM 2
Next, derive another class from Well called HorizontalWell that assigns the attribute well_type = 'horizontal' and takes two positional arguments, depth and length (in that order), and assigns them to attributes called depth and length, respectively. Then implement a member function called compute_wellbore_volume that takes a positional argument diameter and using diameter and the attributes depth and length, computes the total volume of the wellbore. Assume the total wellbore distance is depth + length. See the follow examples for the expected usage of the class and member functions. You should not reimplement the __str__ function in HorizontalWell.
horizontal_well = HorizontalWell(depth = 5000, length = 15000) print(horizontal_well)
will return
'Well type: hortizontal'
Also,
horizontal_well.depth
will return
5000
and
horizontal_well.length
will return
15000
and
horizontal_well.compute_wellbore_volume(diameter = 0.5)
will return
3926.9908169872415
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started