human
Count of subsequences which consists exactly K prime numbers | Returns factorial of n.
Function to return total number of combinations.
Function check whether a number is prime or not.
Corner case.
Check from 2 to n - 1.
Function for finding number of subsequences which consists exactly K primes.
If number of primes are less than k.
Driver code"
How can the above be solved in Python?

What is a code to count of subsequences which consists exactly K prime numbers and the other steps required?
assistant
#Here is code to count of subsequences which consists exactly K prime numbers and the other steps required.
 def fact ( n ) :
	res = 1 ;
	for i in range ( 2 , n + 1 ) :
		res = res * i
	return res
def nCr ( n , r ) :
	return ( fact ( n ) // ( fact ( r ) * fact ( n - r ) ) )
def isPrime ( n ) :
	if ( n <= 1 ) :
		return False ;
	for i in range ( 2 , n ) :
		if ( n % i == 0 ) :
			return False
	return True
def countSubsequences ( arr , n , k ) :
	countPrime = 0
	for i in range ( n ) :
		if ( isPrime ( arr [ i ] ) ) :
			countPrime += 1
	if ( countPrime < k ) :
		return 0
	return ( nCr ( countPrime , k ) * pow ( 2 , ( n - countPrime ) ) )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ]
K = 3
n = len ( arr )
print ( countSubsequences ( arr , n , K ) )