programming help (python, very urgent!!!)
hello, all those out there, I need some help with this question that I need to solve right now.
this is the problem:
x +2y = z; x = 20, z = 36. Write a program to find the value of y, by replacing (looping) integer values from 1 to 100 for y. When the left side equals the right side of the equation, print the value of Z.
can anyone give me the answer or part of the answer to this?
I'll try to explain this step by step. So, when you declare the expression that:
x + 2y = z
x = 20
z = 36
We can substitute the variables in to the equation. So, our equation would now be:
20 + 2y = 36
You want to use a loop (for loop) to find the value of
y. So, you can do the code below:
First, we use the information you gave to substitute into the equation. Then, we use a for loop to find every value of
y from 1 to 100 (101-1, that's how for loops work). We then use a if statement inside to see if the equation is true or not. The else after the if statement is to see if the for loop wasn't breaked. We then print what we solved!