I managed to get thru all the Scientific problems in the second level of Learn Python without posting a forum request, but I’m now stumped.
I will post my repl link below. I do add a number of optional print statements for my own diagnosis and I haven’t removed these yet, but they are commented out. And yes, I know there are extra self checking variables in my function that do not affect the outcome, but make the code slightly slower.
Here is the issue.
The program (finally, sigh!) passes all the test conditions without crashing, except for the last one. Test three consistently flunks it in the second data set.
FAIL: test_prob_experiment (test_module.UnitTests)
Traceback (most recent call last):
File “/home/runner/fcc-probability-calculator/test_module.py”, line 26, in test_prob_experiment
self.assertAlmostEqual(actual, expected, delta = 0.01, msg = ‘Expected experiemnt method to return a different probability.’)
AssertionError: 0.122 != 0.272 within 0.01 delta (0.15000000000000002 difference) : Expected experiemnt method to return a different probability.
Ran 3 tests in 0.073s
Now I’m not sure if it’s how the random seed is generated but the result is always exactly 0.122. Since this is a probability experiment with many random draws, should 0.122 always be the exact same result? When I copy the function call data and run it in my local Py editor, it varies, although it is NEVER anywhere near 0.272
I am wondering if there is an error in the checking routine. It would not be the first that I’ve found. In the Budget Calculator check, one test tries to equate 54 with 854 and amazingly always fails. Note also that there is an obvious typo in the same check line, so the possibility exists of some error, but I do not see anyone else reporting it in the forum.
I am sure that the error is my own lack of knowledge, but if not, does anyone have an idea what the problem is?
Thank you for your help.