Skip to content

Instantly share code, notes, and snippets.

@joonro
Created December 10, 2019 06:03
Show Gist options
  • Save joonro/f161c00d9fd78a57768f4e571edeac5f to your computer and use it in GitHub Desktop.
Save joonro/f161c00d9fd78a57768f4e571edeac5f to your computer and use it in GitHub Desktop.
[Probability of randomly choose r correct answers out of n total questions] #python #teaching
import math
n = 33 # number of questions
r = 6 # number of correct answers
probs = []
for r in range(n):
prob_specific_case = ((1/5)** r * (4/5)** (n-r))
num_comb = math.factorial(n) / (math.factorial(r) * math.factorial(n-r)) * prob_each_case
prob_case = num_comb * prob_specific_case
probs.append(prob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment