Numerous engineering and scientific applications require finding solutions to a set of equations.
Example:
8x + 7y = 38
and
3x - 5y = -1
have a solution x = 3, y = 2.
Given integer coefficients of two linear equations with variables x and y, use brute force to find an integer solution for x and y in the range -10 to 10.
Use this brute force approach:
Initialize variables xSolution, ySolution to 11 (a value they can not equal. For every value of x from -10 to 10 For every value of y from -10 to 10 Check if the current x and y satisfy both equations. If so, save the x and y values in xSolution and ySolution variables. When the loop is done, if the Solution varaibles are not 11, then you found a solution and should display it. Otherwise there was no solution.
You can assume the two equations have no more than one solution.
Required Python elements:
Variables used for inputs, outputs and other values needed for computations.
Proper naming of the variables
Using the input function to get the data
Proper use of mathematical operators
Concatenation of string and integer types
Using nested for loops to perform the calculations.
Example output:
This program will solve a system of linear equations written as:
ax + by = c
dx + ey = f
Enter the following coefficients and constants:
First equation:
a:8
b:7
c:38
Second equation:
d:3
e:-5
f:-1
Solution: x = 3, y = 2
This program will solve a system of linear equations written as:
ax + by = c
dx + ey = f
Enter the following coefficients and constants:
First equation:
a:3
b:2
c:5
Second equation:
d:7
e:5
f:4
No solution
Answers
Answered by
2
Answer:
it's a very big que not able to solve
Similar questions