human
Probability of reaching a point with 2 or 3 steps at a time | Returns probability to reach N.
Driver code"
How can the above be solved in Python?
 ... What is a code to probability of reaching a point with 2 or 3 steps at a time and the other steps required?
assistant
#Here is code to probability of reaching a point with 2 or 3 steps at a time and the other steps required.
 def find_prob ( N , P ) :
	dp = [ 0 ] * ( n + 1 )
	dp [ 0 ] = 1
	dp [ 1 ] = 0
	dp [ 2 ] = P
	dp [ 3 ] = 1 - P
	for i in range ( 4 , N + 1 ) :
		dp [ i ] = ( P ) * dp [ i - 2 ] + ( 1 - P ) * dp [ i - 3 ]
	return dp [ N ]
n = 5
p = 0.2
print ( round ( find_prob ( n , p ) , 2 ) )