I would like to explain a bit of how the program works.
How it Works
First, the program request for inputs a1, a2 and a3, those are the coefficient of the first equation. Then it prompts for the coefficients: b1, b2 and b3, the coefficients of the second equation.
It then solves and display the result for x1 and x2
Source code:
#CATEGORY: PYTHON TUTORIALS
print(“n*** PROGRAM TO SOLVE 2×2 SIMULTANEOUS EQUATIONnn”)
print “nEquation of the form a1x + b1y = c1, a2x + b2y = c2 nnn”
#INPUT THE COEFFICIENTS OF EQUATION 1
a1 = input(“nEnter a1: “)
b1 = input(“nEnter b1: “)
c1 = input(“nEnter c1: “)
#INPUT THE COEFFICIENTS OF EQUATION 2
a2 = input(“nEnter a2: “)
b2 = input(“nEnter b2: “)
c2 = input(“nEnter c2: “)
#USING CRAMER’S RULE…
D = (a1 * b2) – (a2 * b1)
Dx = (c1 * b2) – (c2 * b1)
Dy = (a1 * c2) – (a2 * c1)
x = Dx/D
y = Dy/D
#DISPLAY THE RESULTS
print “*********The results are:******************* nn”
print “x = {}”.format(x)
print “y = {}”.format(y)
raw_input(“nnPress <Enter> to exit…”)