Not getting the expected probability for Project #5 of Scientific Computing with Python

Tell us what’s happening:
While calculating the probability for project no. 5 of Scientific Computing with Python, I am not able to get the expected probability. The delta is always 0.2.

I am not sure whether this is correct or not.

Your code so far
You can check my code at: https://replit.com/@VikhyatSharma17/FreeCodeCamp-Project-5-Probability-Calculator#prob_calculator.py

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

Challenge: Probability Calculator

Link to the challenge:

For a start, if you got 1000 experiments, you definitly need to find a better way to check the results than printing about 7000 lines of text…

Because you obviously don’t actually know what to do with the printed lines to find your mistake anyway ^^°

That being said, the mistake is quite simple: You check if the “expected balls” are EXACTLY present. But the test only wants AT LEAST those numbers.
Example: 2 blue and 1 green expected → 2 blue and 2 green is also a favourable outcome. Your test however does not count that.

Thanks @Jagaya
I thought the expected_balls were the exact number of balls to check for in the output.

When you got 3 expected balls but draw 4 - you obviously cannot expect to get an EXACT match. You have to check if all 3 expected balls are there and it doesn’t matter what the 4th one is.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.