This module is designed to help explorers determine if there is an impenetrable obstruction when digging to the core of the earth. It calculates the expected time for a machine to travel a certain distance and checks if the actual time exceeds the expected time by a specified threshold. If the actual time exceeds the expected time by the specified threshold, then there is an impenetrable obstruction. Otherwise, there is no impenetrable obstruction.
Encapsulation is one of the fundamental principles of OOP that involves bundling data (attributes) and methods (functions) that operate on that data into a single unit, known as a class. The class acts as a blueprint for creating objects that can store and manipulate data in a controlled manner.
def is_impenetrable(expected_time, actual_time):
# ...
Here, the code defines a function (is_impenetrable
) that encapsulates (hide) the logic for determining whether there's an impenetrable obstruction based on the given parameters.
No installation is required for this module as it consists of a single Python file.
No external APIs, No libraries, no frameworks, pure OOP concept.
is_impenetrable
function from the obstruction_class
module into your Python script.from obstruction_class import is_impenetrable
if is_impenetrable(expected_time, actual_time): <br />
print("There is an impenetrable obstruction!.")
else:
print("There is no impenetrable obstruction.!")
expected_time_to_reach.
actual_time
exceeds both the threshold time and the maximum allowed time, it indicates an impenetrable obstruction.Here's an example of how to use the module:
from obstruction_class import is_impenetrable
speed = 10 # Speed in miles per hour
distance = 15 # Distance in miles
location_b = distance / speed * 60 # Expected time in minutes
location_a = 78 # Actual time in minutes
if is_impenetrable(location_b, location_a):
print("There is an impenetrable obstruction!")
else:
print("There is no impenetrable obstruction!")
Run the following command to run the main.py
script:
python main.py
if you are using ubuntu, run the following command:
python3 main.py
This module is designed for learning purposes and may require further enhancements for production use.
Isah Jacob