Created
October 12, 2019 10:26
-
-
Save MM-coder/6d2e6056b58ec07ccd335e9326f7c8e2 to your computer and use it in GitHub Desktop.
Python program to calculate if a interval intersects (2 tuples)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interval_intersect(a, b, c, d): | |
if (c <= b) and (a <= d) == False: | |
return False | |
else: | |
return True | |
def process(input: bool): | |
if input == False: | |
return "does not" | |
else: | |
return "does" | |
a = int(input("Value for a: ")) | |
b = int(input("Value for b: ")) | |
c = int(input("Value for c: ")) | |
d = int(input("Value for d: ")) | |
print(f"The interval [{a},{b}] [{c},{d}] does {process(interval_intersect(a, b, c, d))} intersect") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment