import numpy as np
import random
Total_Iterations = 10000
n = 1000
k = 240
p = 0.25
q = 1- 0.25
hits = 0
for iteration in range(Total_Iterations):
sample = np.random.random((n,))
count = np.count_nonzero(sample < 0.25)
if count >= k:
hits+=1
result = hits/Total_Iterations
print("Using simulation: ",result)

from scipy import special
n = 1000
k = 240
p = 0.25
q = 1-0.25
result = 0
for i in range(k, n+1):
result += special.comb(n,i) * (p**i) * ((1-p)**(n-i))
print("Using Binomial Distribution: ", result)