-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph guide updated.py
61 lines (59 loc) · 2.38 KB
/
graph guide updated.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
50
51
52
53
54
55
56
57
58
59
60
61
import matplotlib.pyplot as plt
ch='y'
while(ch=='y' or ch=='Y'):
try:
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 - (d * 1)) / e)
print("y co-ordinates", i)
print("at x=2")
i1 = ((c - (d * 2)) / e)
print("y co-ordinates", i1)
print("at x=3")
i2 = ((c - (d * 3)) / e)
print("y co-ordinates", i2)
print("at x=4")
i3 = ((c - (d * 4)) / e)
print("y co-ordinates", i3)
plt.bar([1, 2, 3, 4, ], [i, i1, i2, i3])
plt.plot([1, 2, 3, 4, ], [i, i1, i2, i3])
plt.xlabel('X Co-ordinates')
plt.ylabel('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......")
print("at x=1")
i = -((c - (d * 1)) / e)
print("y co-ordinates", i)
print("at x=2")
i1 = -((c - (d * 2)) / e)
print("y co-ordinates", i1)
print("at x=3")
i2 = -((c - (d * 3)) / e)
print("y co-ordinates", i2)
print("at x=4")
i3 = -((c - (d * 4)) / e)
print("y co-ordinates", i3)
plt.bar([1, 2, 3, 4, ], [i, i1, i2, i3])
plt.plot([1, 2, 3, 4, ], [i, i1, i2, i3])
plt.show()
plt.legend()
else:
print("invalid input!!!!! check the above statements")
except:
print("you entered the wrong input")
ch=input("do you want to try again y/n=")
print("thanks for using")