I am trying to solve linear equations with a numpy
array based on user inputs. I've programmed a simple calculator that can deal with every day problems, but I would like to add the feature where you can choose to solve a linear equation.
Exp:
2x + 10 = 20 ==> x = 5
In above example, how would I use user inputs with a numpy
array?
print('Select Mathematical Operation.')
print('1. Addition')
print('2. Subtraction')
print('3. Multiplication')
print('4. Division')
userchoice = input ('Enter choice (1/2/3/4): ')
import numpy as np
x = int(input("Enter x:"))
y = int(input("Enter y:"))
w = int(input("Enter w:"))
a = np.array([[x],[y]])
b = np.array([w])
z = np.linalg.solve(a,b)
return z