Answer to Question #262377 in Python for Kelly

Question #262377

You can use Cramer’s rule to solve the following 2 x 2 system of linear equations: Ax+By=E


Cx+Dy=f


X=ED-Bf/AD-Bc


Y= Af-Ec/AD-Bc



Write a program that prompts the user to enter A, B, C, D, E, and F nd display the


result. If AD – BC is 0, report that “The equation has no solution”.



Do all you can to make your program structure when running, conform with the sample runs


given below:



Enter a, b, c, d, e, f: 9.0, 4.0, 3.0, -5.0, -6.0, -21.0


x is -2.0 and y is 3.0



Enter a, b, c, d, e, f: 1.0, 2.0, 2.0, 4.0, 4.0, 5.0


The equation has no solution

1
Expert's answer
2021-11-07T10:12:48-0500
a,b,c,d,e,f = [float(i) for i in input("Enter a, b, c, d, e, f: ").split(',')]
diff = a*d-b*c
if diff!=0:
    x=(e*d-b*f)/diff
    y=(a*f-e*c)/diff
    print(f"x is {x} and y is {y}")
else:
    print("The equation has no solution")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS