Equation of a straight line

Joined
Jan 9, 2022
Messages
7
Reaction score
0
hello I would like to create a program which by giving the equation of a straight line allows us to draw it, then a program which could determine the point of intersection of two straight lines according to their equations
 
Joined
May 11, 2022
Messages
60
Reaction score
6
i'm not sure how to do the first part, python doesn't have a graph function as far as i know,
but the second part is solvable.
Python:
eq1 = input("the first equation ")
eq2 = input("the second equation ")
eq1 = eq1[3:]
eq2 = eq2[3:]
eqE = eq1+"="+eq2
print("the first step, "+eqE)
slope1 = ""
slope2 = ""
remain1 = ""
remain2 = ""
for i in range(0,len(eq1)):
   if eq1[i] == "x":
      slope1 = eq1[:i]
      remain1 = eq1[i+1:]


for i in range(0,len(eq2)):
   if eq2[i] == "x":
      slope2 = eq2[:i]
      remain2 = eq2[i+1:]
slopeE = str(float(slope1) -float(slope2))


print("the second step "+remain1+"=" +slopeE+"x " + remain2)  


remainE = int(remain1) - int(remain2)
print( "the third step,",remainE, "=", slopeE, "x")
solve = remainE/float(slopeE)
print("x = ", solve)
input()
 

Attachments

  • lineEQuse.png
    lineEQuse.png
    10 KB · Views: 17

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top