This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this program is used to calculate the probability of getting 100% in a test containg only single choice quiestions | |
# x - amount of answers per question | |
# y - amount of questions | |
# formula of the function: x^0 + x^1 + x^2 + x^3 + ... + x^y | |
def probability(x, y): | |
i = 0 | |
z = 0 | |
while(i <= y): | |
z += x ** i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combinations(n,k): | |
def factorial(n): | |
fact = 1 | |
for i in range(1, n+1): | |
fact = fact * i | |
return(fact) | |
result = int(factorial(n) / (factorial(k) * factorial(n-k))) | |
return(f"{result:,}".replace(",", " ")) |