Tell us what’s happening:
Could someone please help me figure out how to troubleshoot this error message?
AssertionError: 0.261 != 0.272 within 0.01 delta (0.01100000000000001 difference) : Expected experiment method to return a different probability.
Any tips or advice would be greatly appreciated. Thanks a bunch!
Best regards,
RR
Your code so far
import copy
import random
def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
experiments_num = 0
hat_contents = copy.copy(hat.contents)
sgrawk = {
ball: hat_contents.count(ball)
for ball in set(hat_contents)
}
for _ in range(num_experiments):
hat_copy = Hat(**sgrawk)
balls_drawn = hat_copy.draw(num_balls_drawn)
drawn_counts = {
ball_drawn: balls_drawn.count(ball_drawn)
for ball_drawn in set(balls_drawn)
}
success = all(
drawn_counts.get(color, 0) >= count
for color, count in expected_balls.items()
)
if success:
experiments_num += 1
return experiments_num / num_experiments
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Challenge Information:
Build a Probability Calculator Project - Build a Probability Calculator Project