EDIT:
Updating this in hopes that someone finds it useful. Commenting out the line of random.seed() generation into ‘#prob_calculator.random.seed(95)’ successfully solves my problem. As expected, it will randomly pass and fail the unittest. I hope this is not viewed as spam as that was never my intent with this post. Thanks!
Hello fellow Campers!
First off, I apologize if I didn’t post this in the right section, but I assume this location is appropriate.
Anyways, I’ve been working through the “Scientific Computing with Python” course projects for the last few weeks, and this week, have been working on the ‘Probability Calculator’ challenge:
My code only fails one of the three tests now, :
“”"
Traceback (most recent call last):
File “/home/runner/[REDACTED]/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.248 != 0.272 within 0.01 delta (0.02400000000000002 difference) : Expected experiemnt method to return a different probability.
“”".
The issue is that, when I run this code / test inside the FCC provided REPL link, it always fails this single test, ALWAYS with a probability of 0.248, with no variation regardless of how many times the code is run ;
However when I replicate the test conditions outside of the FCC REPL link(i.e. my own computer, or a completely vanilla repl link), the resulting probability varies, as it should, and quite often well within the .01 delta. Does anyone have any insight on what may be happening? I will hold off on posting my code at the moment, for plagiarism purposes.
Any help is greatly appreciated!