Rain in N Days
Start Timer
0:00:00
The probability that it will rain tomorrow is dependent on whether or not it is raining today and whether or not it rained yesterday.
If it rained yesterday and today, there is a 20% chance it will rain tomorrow. If it rained one of the days, there is a 60% chance it will rain tomorrow. If it rained neither today nor yesterday, there is a 20% chance it will rain tomorrow.
Given that it is raining today and that it rained yesterday, write a function rain_days
to calculate the probability that it will rain on the nth day after today.
Example:
Input:
n=5
Output:
def rain_days(n) -> 0.39968
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments