from math import comb
# 설정 변수
total_numbers = 80 # 총 번호 개수
winning_numbers = 6 # 당첨 번호 개수
chosen_numbers = 24 # 사용자가 고르는 번호 개수
# 전체 경우의 수
total_combinations = comb(total_numbers, chosen_numbers)
# 맞춘 개수별 확률 계산
results = {}
for k in range(winning_numbers + 1): # 0~6개 맞춤
if k <= chosen_numbers: # 사용자가 고른 번호보다 많이 맞출 수는 없음
matching_combinations = comb(winning_numbers, k)
non_matching_combinations = comb(total_numbers - winning_numbers, chosen_numbers - k)
probability = (matching_combinations * non_matching_combinations) / total_combinations
results[k] = probability
# 결과 출력
for k, probability in results.items():
print(f"{k}개 맞춤: {probability * 100:.4f}%")
To embed this project on your website, copy the following code and paste it into your website's HTML: