print:
- a single integer solution for x if it exists or "no solution"
- or "no integer solution" if the answer is a floating point number
- or "many solutions".
Let's first think about the math: You have the equation a*x = b
and you want to find x
. The first step is to solve this equation on paper so that you get it to the form x = ...
.
Now you will have a division in there. And divisions are always risky because if you divide by zero, you will get a ZeroDivisionError
. So In the program, I would first of all handle that case. Think about what it should do when that variable is indeed zero.
so i dont know in what condition would x have 1 solution in this linear equation
In most cases. The only reason to have more or less than 1 solution is if either a division by zero happens or there is no integer solution at all.
To check if there is an integer solution, you can use the modulo operator. Or you could compute the integer result and then compute it backwards again to see if you get the result that was your input.
To code this, I think you have understood how if
and elif
work. Just make sure you have the same number of whitespace in front of the indented lines that should be at the same level. Otherwise it will probably not run.