Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlover101 authored Jan 26, 2022
1 parent ce8b775 commit 4b4f777
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,69 +69,8 @@ def quadsolve():
print("\nSolution 1:",x1)
print("Solution 2:",x2)


def slopeint():
import re
yint = ""
eq = input("Enter two points (ex. (1,-1),(2,-1) ): ")
eq = eq.split(",")
point1 = re.sub("[^0-9.-]","",eq[0])
point2 = re.sub("[^0-9.-]","",eq[1])
point3 = re.sub("[^0-9.-]","",eq[2])
point4 = re.sub("[^0-9.-]","",eq[3])
rise = float(point4) - float(point2)
run = float(point3) - float(point1)
if rise/run == 1.0:
slope = 1
calc = 0
elif rise/run == -1.0:
slope = -1
calc = 0
else:
slope = rise/run
calc = 1
yint = [float(point1),float(point2)]
if calc == 0:
if float(point1) != 0:
yint[0] -= float(point1)
yint[1] -= float(point1)
elif calc == 1:
start = [0,0]
for i in range(5):
start[1] -= 0.01
slope2 = float(point3) - start[0]/float(point4) - start[1]
if slope == slope2:
break
slope2 = -1*slope2
if slope == slope2:
break
slope2 = -1*slope2
if yint == [0.0,0.0]:
if calc == 0:
print(f"y = {slope}x")
elif run == -1.0:
print(f"y = {-1*rise}x")
else:
print(f"y = {rise}/{run}x")
elif calc == 0:
if yint[1] > 0:
print(f"y = {slope}x + {yint[1]}")
elif yint[1] < 0:
print(f"y = {slope}x {yint[1]}")
elif run == -1.0:
if yint[1] > 0:
print(f"y = {-1*rise}x + {yint[1]}")
elif yint[1] < 0:
print(f"y = {-1*rise}x {yint[1]}")
else:
if yint[1] > 0:
print(f"y = {rise}/{run}x + {yint[1]}")
elif yint[1] < 0:
print(f"y = {rise}/{run}x {yint[1]}")

if "__name__" == "__eqsolvecarlover101__":
equation.quadsolve()
equation.slopeint()
equation.commands()

os.system("clear")
Expand Down

0 comments on commit 4b4f777

Please sign in to comment.