-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph guide.py
49 lines (47 loc) · 1.52 KB
/
graph guide.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Graph Representation.
import matplotlib.pyplot as plt
print("this will only work on linear graphs")
c=int(input("enter the value of the constant="))
a=input("enter the given first variable of equation such as{a,x,y}=")
b=input("enter the given second variable of equation such as{a,x,y}=")
d=int(input("enter the coefficient of first variable if there is no coefficient simply input 1="))
e=int(input("enter the coefficient of second variable if there is no coefficient simply input 1="))
f= str(d)+a
g= str(e)+b
h=input("the operator between the equation such as sum, substract=")
if h=='sum' or h=='+':
print("your equation is",f,'+',g,"=",c)
print("equating points of the line......")
print("at x=1")
i=-c/(e*1)
print("y co-ordinates",i)
print("at x=2")
i1=-c/(e*2)
print("y co-ordinates",i1)
print("at x=3")
i2=-c/(e*3)
print("y co-ordinates", i2)
print("at x=4")
i3=-c/(e*4)
print("y co-ordinates", i3)
plt.plot(1, 2, 3, 4, label="x co-ordinates")
plt.plot(i, i1, i2,i3, label="y co-ordinates")
plt.legend()
plt.show()
elif h=='substract' or h=='-':
print("your equation is", f, '-', g, "=", c)
print("equating points of the line......")
# let x=0
i=-1*(c/e)
print("y co-ordinates",'-',i)
# let y=0
j=-1*(c/d)
print("x co-ordinates",'-',j)
k = 0
plt.plot(k, i, label="x co-ordinates")
p = 0
plt.plot(j, p, label="y co-ordinates")
plt.legend()
plt.show()
else:
print("invalid input!!!!! check the above statements")