Quote:
Like what does each line of code do
What each line of code does is obvious: none of them are complicated - simple compares and assignments mostly. The only vague complexity is the last two lines which do the "donkey work" and they are also self explanatory.
If you don't understand the individual lines, then you need to go back to the beginning of your Python course, and learn the basics properly because nobody is going to do a "line by line" explanation of basic code for you": Do you have any idea how much work explaining code line by line is?
Every single line needs a paragraph of explanation! For example:
int next = r.Next();
Create a new variable called "next" which can hold a integer value. From the previously declared Random instance "r", call the "Next" method to get a new random number, and assign it to the "next" variable.
Can you imagine how long it would take us to explain even a very short code fragment like your example, line by line? Would you want to sit down for 45 minutes and type up a line-by-line description for no good reason?
A better question would be "what does this function do?" And to be honest, I have no idea whatsoever - mostly because I have no idea what values you are supposed to pass into the function as the
triangle
parameter. I could guess based on "it's probably 1.0 or -1.0" but even then I'm not sure what the function is supposed to used for - the name
magic
implies that it's not supposed to be anything particularly sensible.
So go back to wherever you got the code from, and look at it in context: when is it called, what parameters does it get, what is done with the result?
But don't expect line by line translations os basic code to happen or that they would necessarily be of any use if they did happen.