C3_W1_Assignment exercise 5&6

I have unexpected outcomes in exercise 5 and 6, and am struggling with fixing them. Here’s my code and outputs. Could anyone advise? Thanks.

Exercise 5
{moderator edit: code removed}

Exercise 6
{moderator edit: code removed}

1 Like

Please do not post your code on the forum. That is not allowed by the Code of Conduct.

I recommend you read the tips for this assignment, from the FAQ.

You can find it by using the forum search tool for “M4ML Resources FAQ”.

1 Like

Thanks for your reply. Hmm, I believe you’re referring to this, but still cannot think of how I should fix the code.

1 Like

The error says UnboundLocalError: local variable 'probability_f' referenced before assignment, but that doesn’t make sense to me as I don’t think 'probability_f is used before Exercise 6.

1 Like

What that means is your code tried to use the probability_f variable before it ran any code that assigned it a value.

1 Like

It has been sorted. Thanks.

1 Like