Hello ppl.
I am on the final project of Scientific Computing with Python, and I am stuck with the tests.
Something strange (at least for me) happens. If I run the tests, the test_hat_draw and test_prob_experiment. But what I come to ask is about the first one.
I always get the same list with 2 red balls, resulting in a failed test. But if I comment everything and from main I just call the draw method, I do get different results.
And to make it even stranger, if I comment the first and third tests, test_hat_draw passes correctly:
At the beggining, declaring those “globals” inside functions was the only way I found to not get errors related with the variables not being declared. Somehow I missunderstood its use.
Anyway, I have commented every global declaration, but the results are just the same. It still puzzles me how the fact that a test is preceded by another, changes its results.
That’s because they are still global. You are creating those variables once and reusing the same variable every time. You want to look into the difference between class and instance variables in Python.