0

This is the problem I'm writing my code off of:

You are planning a picnic today, but the morning is cloudy

Oh no! 50% of all rainy days start off cloudy! But cloudy mornings are common (about 40% of days start cloudy) And this is usually a dry month (only 3 of 30 days tend to be rainy, or 10%) What is the chance of rain during the day?

We will use Rain to mean rain during the day, and Cloud to mean cloudy morning.

The chance of Rain given Cloud is written P(Rain|Cloud)

P(Rain) is Probability of Rain = 10%

P(Cloud|Rain) is Probability of Cloud, given that Rain happens = 50%

P(Cloud) is Probability of Cloud = 40%

*Answer should be 12.5% chance of rain. *

https://www.mathsisfun.com/data/bayes-theorem.html

probability = (0.1*0.5)/(0.4)

def p(probability): return (probability)

print('Probability to rain is:', bayes(probability))

1 Answers1

0

The problem is that bayes is not a function you've defined, you need to rename your function p to bayes.

You will then get this output:

Probability to rain is: 0.125

However, p as a function seems redundant in the first place, you can just print the probability directly like so:

print('Probability to rain is:', probability).

Mario Ishac
  • 5,060
  • 3
  • 21
  • 52