Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. import math
  2. def probability(n,p):
  3.     prob = math.factorial(n) /math.factorial(n-p)  * math.factorial(p)
  4.     return prob
  5.  
  6.  
  7. def main():
  8.     n = int(input("Enter the number of lottery balls: "))
  9.     p = int(input("Enter the number of drawn balls: "))
  10.     if n <= 0:
  11.         print("The number of balls must be a positive number.")
  12.     if p > 39:
  13.         print("Ar most the total number of balls can be drawn.")
  14.     else:
  15.         print("The probability of guessing all", n ,"balls correctly is", probability(n,p))
  16. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement