Was ist bei diesem Programm bei Python falsch?
Hallo,
was ist bei diesem Programm bei Python falsch? Ich wollte testen, ob manunter der Bedingung m>n mit der Formel für pythagoreische Tripel (a = m² – n² ; b = 2mn ; c = m² + n²) jede beliebige Zahl für m und n einsetzen kann und dann automatisch ein pythagoreisches Tripel erhält.
Your mistake in the program is that the engagement is wrong.
After the if at least one line is expected to run at True. For this, after the If, an indentation is required for all rows. The same applies to Else.
So return the last two print calls. Then the program will run through.
You also have a mistake in your formula.
Currently you have: m2 – 2n
You probably want: m2 – n2
To do this, you have to replace the + with an *.
Python also offers easier possibility to square. “m*m” you can also use “m**2” or “pow(m, 2). Your intention should be clearer and you only have to write “m[i]” once, where more mistakes could occur.
The only thing that might be wrong is that this command “print ” is in red. In addition to the other, too:(
The green ones are right.
But these red areas indicate a mistake.
At least it’s mine.
Try to add the lower print Pythagoreic Tripel to the false.
Because there is true and false.
At least that’s fine with me.
Can you all not read any error messages??
You calculate a = m2 – n+n (instead n2).