소개
이 튜토리얼에서는 Python 을 사용하여 고유한 무작위 로또 번호를 생성하는 방법을 살펴봅니다. 이 기술은 로또 시뮬레이션, 게임을 만들거나, 로또를 할 때 자신만의 번호를 선택하는 데 유용합니다. Python 의 random 모듈을 사용하여 반복되지 않는 숫자를 생성하는 방법을 배우게 되는데, 이는 로또 시스템의 기본적인 요구 사항입니다. 이 Lab 이 끝나면 신뢰할 수 있고 고유한 숫자 세트를 생성하는 자신만의 로또 번호 생성기를 만들 수 있습니다.
Python 의 Random 모듈 이해
로또 번호 생성기를 만드는 첫 번째 단계는 Python 이 난수를 처리하는 방식을 이해하는 것입니다. 이 단계에서는 Python 의 표준 라이브러리에 내장된 random 모듈을 살펴봅니다.
첫 번째 Python 파일 만들기
프로젝트 디렉토리에 새 Python 파일을 만들어 보겠습니다.
- WebIDE 를 열고 파일 탐색기 패널로 이동합니다.
~/project/lottery디렉토리로 이동합니다.- 파일 탐색기 패널에서 마우스 오른쪽 버튼을 클릭하고 "New File"을 선택합니다.
- 파일 이름을
random_basics.py로 지정합니다.
이 파일에서 random 모듈의 기본 기능을 살펴봅니다.
Random 모듈 가져오기
먼저 random 모듈을 가져와서 몇 가지 기본 난수를 생성하는 코드를 작성해 보겠습니다.
## Import the random module
import random
## Generate a random float between 0 and 1
random_float = random.random()
print(f"Random float between 0 and 1: {random_float}")
## Generate a random integer between 1 and 10
random_int = random.randint(1, 10)
print(f"Random integer between 1 and 10: {random_int}")
## Generate a random integer from a range with a step
random_range = random.randrange(0, 101, 10) ## 0, 10, 20, ..., 100
print(f"Random number from range (0, 101, 10): {random_range}")
파일을 저장하고 터미널을 열어 다음을 실행하여 실행합니다.
cd ~/project/lottery
python3 random_basics.py
다음과 유사한 출력을 볼 수 있습니다.
Random float between 0 and 1: 0.7234567890123456
Random integer between 1 and 10: 7
Random number from range (0, 101, 10): 50
프로그램을 실행할 때마다 다른 난수를 얻게 됩니다.
무작위성 및 시드 이해
컴퓨터의 난수 생성기는 진정한 무작위가 아니라 "의사 난수"입니다. "시드 (seed)"라고 하는 시작 값을 사용하여 무작위로 보이는 일련의 숫자를 생성합니다. 동일한 시드를 설정하면 동일한 일련의 "난수"를 얻게 됩니다.
시드를 실험해 보겠습니다. 다음 코드를 random_basics.py 파일에 추가합니다.
## Setting a specific seed
print("\n--- Demonstrating Seeds ---")
random.seed(42)
print(f"First random number with seed 42: {random.randint(1, 100)}")
print(f"Second random number with seed 42: {random.randint(1, 100)}")
## Reset the seed to get the same sequence
random.seed(42)
print(f"First random number with seed 42 again: {random.randint(1, 100)}")
print(f"Second random number with seed 42 again: {random.randint(1, 100)}")
프로그램을 저장하고 다시 실행합니다.
python3 random_basics.py
시드를 42 로 다시 설정한 후 동일한 일련의 난수를 다시 얻는 것을 알 수 있습니다. 이는 동일한 시드를 사용할 때 무작위성이 결정론적임을 보여줍니다.
출력은 다음과 같아야 합니다.
--- Demonstrating Seeds ---
First random number with seed 42: 24
Second random number with seed 42: 33
First random number with seed 42 again: 24
Second random number with seed 42 again: 33
로또 애플리케이션의 경우 특정 시드를 설정하지 않고 Python 이 더 나은 무작위성을 위해 시스템 시간을 기반으로 시드를 사용하도록 합니다.
기본 로또 번호 생성
이제 Python 에서 난수를 생성하는 방법을 이해했으므로 고유한 로또 번호를 만드는 데 집중해 보겠습니다. 대부분의 로또 게임은 특정 범위 내에서 고유한 숫자 집합을 필요로 합니다.
고유한 숫자에 random.sample 사용
random.sample() 함수는 시퀀스에서 고유한 요소를 선택하므로 로또 번호를 생성하는 데 완벽합니다. 이 함수를 실험하기 위해 새 파일을 만들어 보겠습니다.
- WebIDE 에서
~/project/lottery디렉토리로 이동합니다. basic_lottery.py라는 새 파일을 만듭니다.
파일에 다음 코드를 추가합니다.
import random
## Generate 6 unique numbers from 1 to 49 (common lottery format)
lottery_numbers = random.sample(range(1, 50), 6)
print(f"Your lottery numbers are: {lottery_numbers}")
## Sort the numbers (many lottery displays show numbers in ascending order)
lottery_numbers.sort()
print(f"Your lottery numbers (sorted): {lottery_numbers}")
## Generate a different lottery format (e.g., 5 numbers from 1-69 and 1 from 1-26)
main_numbers = random.sample(range(1, 70), 5)
special_number = random.randint(1, 26)
print(f"Main numbers: {sorted(main_numbers)}, Special number: {special_number}")
파일을 저장하고 터미널에서 실행합니다.
cd ~/project/lottery
python3 basic_lottery.py
다음과 유사한 출력을 볼 수 있습니다.
Your lottery numbers are: [23, 8, 45, 17, 34, 9]
Your lottery numbers (sorted): [8, 9, 17, 23, 34, 45]
Main numbers: [4, 28, 35, 47, 62], Special number: 13
random.sample 작동 방식 이해
random.sample(population, k) 함수는 두 개의 인수를 사용합니다.
population- 샘플링할 시퀀스 (이 경우range(1, 50))k- 선택할 고유 요소의 수 (이 경우6)
이 함수는 선택된 모든 요소가 고유한지 확인합니다. 로또 게임은 중복 없이 고유한 숫자를 요구하므로 로또 번호에 적합합니다.
대체 방법: Set 사용
고유한 로또 번호를 생성하는 또 다른 방법은 고유한 요소만 저장하는 Python set 을 사용하는 것입니다. 이 대체 접근 방식을 파일에 추가해 보겠습니다.
## Alternative approach using a set
print("\n--- Alternative approach using a set ---")
lottery_numbers_set = set()
## Keep adding random numbers until we have 6 unique numbers
while len(lottery_numbers_set) < 6:
lottery_numbers_set.add(random.randint(1, 49))
print(f"Lottery numbers using set: {sorted(lottery_numbers_set)}")
프로그램을 저장하고 다시 실행합니다.
python3 basic_lottery.py
이제 추가 출력을 볼 수 있습니다.
--- Alternative approach using a set ---
Lottery numbers using set: [4, 12, 27, 39, 44, 49]
두 방법 모두 동일한 결과, 즉 고유한 난수 집합을 생성합니다. 차이점은 이를 달성하는 방식입니다.
random.sample()은 한 번에 고유한 요소를 선택합니다.- set 접근 방식은 숫자를 하나씩 추가하여 중복을 자동으로 처리합니다.
대부분의 로또 애플리케이션의 경우 random.sample()이 더 효율적이지만 두 가지 접근 방식을 모두 이해하면 프로그래밍에 유연성을 얻을 수 있습니다.
재사용 가능한 로또 번호 생성기 함수 만들기
이제 고유한 난수를 생성하는 방법을 이해했으므로 로또 번호 생성기를 위한 재사용 가능한 함수를 만들어 보겠습니다. 이렇게 하면 코드가 더 체계적이고 다양한 로또 형식에 대한 번호를 쉽게 생성할 수 있습니다.
함수 파일 만들기
로또 함수가 있는 새 파일을 만들어 보겠습니다.
- WebIDE 에서
~/project/lottery디렉토리로 이동합니다. lottery_functions.py라는 새 파일을 만듭니다.
다음 코드를 추가하여 로또 번호 생성기 함수를 정의합니다.
import random
def generate_lottery_numbers(count, min_num, max_num):
"""
Generate a specified count of unique random numbers within a given range.
Args:
count (int): Number of unique numbers to generate
min_num (int): Minimum value (inclusive)
max_num (int): Maximum value (inclusive)
Returns:
list: Sorted list of unique random numbers
"""
## Validate inputs
if count > (max_num - min_num + 1):
raise ValueError(f"Cannot generate {count} unique numbers in range {min_num}-{max_num}")
## Generate unique random numbers
numbers = random.sample(range(min_num, max_num + 1), count)
## Sort the numbers
numbers.sort()
return numbers
def generate_powerball_numbers():
"""
Generate numbers for Powerball lottery (5 numbers from 1-69 and 1 from 1-26).
Returns:
tuple: (list of main numbers, powerball number)
"""
main_numbers = generate_lottery_numbers(5, 1, 69)
powerball = random.randint(1, 26)
return (main_numbers, powerball)
def generate_mega_millions_numbers():
"""
Generate numbers for Mega Millions lottery (5 numbers from 1-70 and 1 from 1-25).
Returns:
tuple: (list of main numbers, mega ball number)
"""
main_numbers = generate_lottery_numbers(5, 1, 70)
mega_ball = random.randint(1, 25)
return (main_numbers, mega_ball)
이제 함수를 테스트할 파일을 만들어 보겠습니다.
- WebIDE 에서
test_lottery_functions.py라는 새 파일을 만듭니다.
다음 코드를 추가하여 함수를 테스트합니다.
import lottery_functions
## Test standard lottery function (e.g., 6 numbers from a range of 1-49)
standard_lottery = lottery_functions.generate_lottery_numbers(6, 1, 49)
print(f"Standard lottery (6 from 1-49): {standard_lottery}")
## Test Powerball function
main_numbers, powerball = lottery_functions.generate_powerball_numbers()
print(f"Powerball: Main numbers: {main_numbers}, Powerball: {powerball}")
## Test Mega Millions function
main_numbers, mega_ball = lottery_functions.generate_mega_millions_numbers()
print(f"Mega Millions: Main numbers: {main_numbers}, Mega Ball: {mega_ball}")
## Test with different parameters
custom_lottery = lottery_functions.generate_lottery_numbers(4, 1, 20)
print(f"Custom lottery (4 from 1-20): {custom_lottery}")
## Test error handling - Try to generate too many numbers
try:
## Trying to get 10 numbers from a range of only 5 numbers (impossible)
impossible_lottery = lottery_functions.generate_lottery_numbers(10, 1, 5)
except ValueError as e:
print(f"Error caught successfully: {e}")
테스트 파일을 실행하여 함수가 작동하는 것을 확인합니다.
cd ~/project/lottery
python3 test_lottery_functions.py
다음과 유사한 출력을 볼 수 있습니다.
Standard lottery (6 from 1-49): [4, 17, 23, 26, 39, 48]
Powerball: Main numbers: [3, 18, 27, 42, 61], Powerball: 13
Mega Millions: Main numbers: [7, 24, 31, 52, 67], Mega Ball: 9
Custom lottery (4 from 1-20): [2, 9, 15, 19]
Error caught successfully: Cannot generate 10 unique numbers in range 1-5
함수 사용의 이점
이러한 재사용 가능한 함수를 생성함으로써 몇 가지 중요한 프로그래밍 목표를 달성했습니다.
- 코드 재사용성: 코드를 복제하지 않고 프로그램의 어느 곳에서나 로또 번호를 생성할 수 있습니다.
- 입력 유효성 검사: 함수는 요청된 고유 값의 수가 지정된 범위 내에서 가능한지 확인합니다.
- 추상화 (Abstraction): 설명적인 이름으로 함수 내부에 구현 세부 정보를 숨겼습니다.
- 특수화된 함수: 일반적인 로또 형식에 대한 특정 함수를 만들었습니다.
이 모듈식 접근 방식은 코드를 더 쉽게 유지 관리하고 이해할 수 있도록 합니다. 다음 단계에서는 이러한 함수를 사용하여 사용자 인터페이스가 있는 완전한 로또 애플리케이션을 만들 것입니다.
완전한 로또 애플리케이션 구축
이제 핵심 로또 함수가 있으므로 사용자 인터페이스가 있는 완전한 애플리케이션을 구축해 보겠습니다. 사용자가 다양한 로또 게임에 대한 번호를 생성할 수 있는 간단한 명령줄 인터페이스를 만들 것입니다.
메인 애플리케이션 만들기
메인 애플리케이션 파일을 만들어 보겠습니다.
- WebIDE 에서
~/project/lottery디렉토리로 이동합니다. lottery_app.py라는 새 파일을 만듭니다.
다음 코드를 추가하여 간단한 메뉴 기반 애플리케이션을 만듭니다.
import lottery_functions
import time
def print_header():
"""Display the application header"""
print("\n" + "=" * 50)
print(" PYTHON LOTTERY NUMBER GENERATOR")
print("=" * 50)
print("Generate random numbers for various lottery games")
print("-" * 50)
def print_menu():
"""Display the main menu options"""
print("\nSelect a lottery game:")
print("1. Standard Lottery (6 numbers from 1-49)")
print("2. Powerball (5 numbers from 1-69 + 1 from 1-26)")
print("3. Mega Millions (5 numbers from 1-70 + 1 from 1-25)")
print("4. Custom Lottery")
print("5. Exit")
return input("\nEnter your choice (1-5): ")
def get_custom_lottery_params():
"""Get parameters for a custom lottery from the user"""
try:
count = int(input("How many numbers do you want to generate? "))
min_num = int(input("Enter the minimum number: "))
max_num = int(input("Enter the maximum number: "))
return count, min_num, max_num
except ValueError:
print("Please enter valid numbers")
return get_custom_lottery_params()
def main():
"""Main application function"""
print_header()
while True:
choice = print_menu()
if choice == '1':
## Standard Lottery
numbers = lottery_functions.generate_lottery_numbers(6, 1, 49)
print("\nYour Standard Lottery numbers are:")
print(f" {numbers}")
elif choice == '2':
## Powerball
main_numbers, powerball = lottery_functions.generate_powerball_numbers()
print("\nYour Powerball numbers are:")
print(f" Main numbers: {main_numbers}")
print(f" Powerball: {powerball}")
elif choice == '3':
## Mega Millions
main_numbers, mega_ball = lottery_functions.generate_mega_millions_numbers()
print("\nYour Mega Millions numbers are:")
print(f" Main numbers: {main_numbers}")
print(f" Mega Ball: {mega_ball}")
elif choice == '4':
## Custom Lottery
print("\nCustom Lottery Setup:")
count, min_num, max_num = get_custom_lottery_params()
try:
numbers = lottery_functions.generate_lottery_numbers(count, min_num, max_num)
print(f"\nYour Custom Lottery numbers are:")
print(f" {numbers}")
except ValueError as e:
print(f"Error: {e}")
elif choice == '5':
## Exit
print("\nThank you for using the Python Lottery Number Generator!")
print("Goodbye!\n")
break
else:
print("\nInvalid choice. Please select 1-5.")
## Pause before showing the menu again
input("\nPress Enter to continue...")
if __name__ == "__main__":
main()
애플리케이션을 실행합니다.
cd ~/project/lottery
python3 lottery_app.py
다음과 같은 메뉴 인터페이스가 표시됩니다.
==================================================
PYTHON LOTTERY NUMBER GENERATOR
==================================================
Generate random numbers for various lottery games
--------------------------------------------------
Select a lottery game:
1. Standard Lottery (6 numbers from 1-49)
2. Powerball (5 numbers from 1-69 + 1 from 1-26)
3. Mega Millions (5 numbers from 1-70 + 1 from 1-25)
4. Custom Lottery
5. Exit
Enter your choice (1-5):
각 옵션을 시도하여 애플리케이션이 어떻게 작동하는지 확인합니다. 예를 들어 옵션 1 을 선택하면 다음과 같은 출력이 표시됩니다.
Your Standard Lottery numbers are:
[7, 12, 23, 35, 41, 47]
애플리케이션 탐색
이 애플리케이션은 몇 가지 중요한 프로그래밍 개념을 보여줍니다.
- 사용자 인터페이스 (User Interface): 간단한 텍스트 기반 메뉴 시스템을 만들었습니다.
- 입력 유효성 검사: 사용자 입력을 검증하고 오류를 적절하게 처리합니다.
- 함수 호출: 이전 단계에서 로또 함수를 사용합니다.
- 애플리케이션 흐름: 사용자가 종료하도록 선택할 때까지 프로그램이 계속 실행됩니다.
구조는 또한 좋은 프로그래밍 방식을 따릅니다.
- 코드는 특정 목적을 가진 함수로 구성됩니다.
if __name__ == "__main__"패턴을 사용하여 스크립트를 가져오고 실행할 수 있도록 합니다.- 사용자 입력은 명확한 프롬프트와 유효성 검사로 처리됩니다.
사용자 지정 로또 옵션 (4) 을 사용하여 다양한 로또 형식에 대한 번호를 생성하여 실험해 보십시오.
기록 및 통계 추가
생성된 번호를 추적하고 간단한 통계를 표시하는 기능을 추가하여 로또 애플리케이션을 향상시켜 보겠습니다. 이 기능을 통해 사용자는 패턴을 식별하거나 어떤 번호가 가장 자주 생성되었는지 확인할 수 있습니다.
통계 모듈 만들기
먼저 번호 기록 및 통계를 추적하기 위한 새 파일을 만들어 보겠습니다.
- WebIDE 에서
~/project/lottery디렉토리로 이동합니다. lottery_stats.py라는 새 파일을 만듭니다.
다음 코드를 추가합니다.
class LotteryStats:
def __init__(self):
"""Initialize the statistics tracker"""
self.history = [] ## List to store all generated sets of numbers
self.frequency = {} ## Dictionary to track frequency of each number
def add_draw(self, numbers):
"""
Add a new set of numbers to the history and update frequency counts
Args:
numbers (list): The lottery numbers that were drawn
"""
## Add to history
self.history.append(numbers)
## Update frequency counts
for num in numbers:
if num in self.frequency:
self.frequency[num] += 1
else:
self.frequency[num] = 1
def get_most_common(self, count=5):
"""
Get the most frequently drawn numbers
Args:
count (int): Number of top frequencies to return
Returns:
list: List of (number, frequency) tuples
"""
## Sort frequency dictionary by values (descending)
sorted_freq = sorted(self.frequency.items(), key=lambda x: x[1], reverse=True)
## Return the top 'count' items (or all if fewer)
return sorted_freq[:min(count, len(sorted_freq))]
def get_draw_count(self):
"""Get the total number of draws recorded"""
return len(self.history)
def get_last_draws(self, count=5):
"""
Get the most recent draws
Args:
count (int): Number of recent draws to return
Returns:
list: List of recent draws
"""
return self.history[-count:]
메인 애플리케이션 업데이트
이제 lottery_app.py 파일을 수정하여 통계 추적을 포함해 보겠습니다. 파일을 열고 내용을 다음으로 바꿉니다.
import lottery_functions
import lottery_stats
import time
def print_header():
"""Display the application header"""
print("\n" + "=" * 50)
print(" PYTHON LOTTERY NUMBER GENERATOR")
print("=" * 50)
print("Generate random numbers for various lottery games")
print("-" * 50)
def print_menu():
"""Display the main menu options"""
print("\nSelect an option:")
print("1. Standard Lottery (6 numbers from 1-49)")
print("2. Powerball (5 numbers from 1-69 + 1 from 1-26)")
print("3. Mega Millions (5 numbers from 1-70 + 1 from 1-25)")
print("4. Custom Lottery")
print("5. View Statistics")
print("6. Exit")
return input("\nEnter your choice (1-6): ")
def get_custom_lottery_params():
"""Get parameters for a custom lottery from the user"""
try:
count = int(input("How many numbers do you want to generate? "))
min_num = int(input("Enter the minimum number: "))
max_num = int(input("Enter the maximum number: "))
return count, min_num, max_num
except ValueError:
print("Please enter valid numbers")
return get_custom_lottery_params()
def display_statistics(stats):
"""Display lottery statistics"""
print("\n" + "=" * 50)
print(" LOTTERY STATISTICS")
print("=" * 50)
## Get basic stats
draw_count = stats.get_draw_count()
print(f"Total draws: {draw_count}")
if draw_count == 0:
print("No lottery numbers have been generated yet.")
return
## Show most common numbers
print("\nMost common numbers:")
for num, freq in stats.get_most_common():
print(f" Number {num}: drawn {freq} times ({freq/draw_count:.1%})")
## Show recent draws
print("\nMost recent draws:")
for i, draw in enumerate(stats.get_last_draws()):
print(f" Draw {draw_count-i}: {draw}")
def main():
"""Main application function"""
print_header()
## Initialize the statistics tracker
stats = lottery_stats.LotteryStats()
while True:
choice = print_menu()
if choice == '1':
## Standard Lottery
numbers = lottery_functions.generate_lottery_numbers(6, 1, 49)
stats.add_draw(numbers) ## Add to statistics
print("\nYour Standard Lottery numbers are:")
print(f" {numbers}")
elif choice == '2':
## Powerball
main_numbers, powerball = lottery_functions.generate_powerball_numbers()
stats.add_draw(main_numbers + [powerball]) ## Add to statistics
print("\nYour Powerball numbers are:")
print(f" Main numbers: {main_numbers}")
print(f" Powerball: {powerball}")
elif choice == '3':
## Mega Millions
main_numbers, mega_ball = lottery_functions.generate_mega_millions_numbers()
stats.add_draw(main_numbers + [mega_ball]) ## Add to statistics
print("\nYour Mega Millions numbers are:")
print(f" Main numbers: {main_numbers}")
print(f" Mega Ball: {mega_ball}")
elif choice == '4':
## Custom Lottery
print("\nCustom Lottery Setup:")
count, min_num, max_num = get_custom_lottery_params()
try:
numbers = lottery_functions.generate_lottery_numbers(count, min_num, max_num)
stats.add_draw(numbers) ## Add to statistics
print(f"\nYour Custom Lottery numbers are:")
print(f" {numbers}")
except ValueError as e:
print(f"Error: {e}")
elif choice == '5':
## View Statistics
display_statistics(stats)
elif choice == '6':
## Exit
print("\nThank you for using the Python Lottery Number Generator!")
print("Goodbye!\n")
break
else:
print("\nInvalid choice. Please select 1-6.")
## Pause before showing the menu again
input("\nPress Enter to continue...")
if __name__ == "__main__":
main()
업데이트된 애플리케이션을 실행합니다.
cd ~/project/lottery
python3 lottery_app.py
여러 세트의 로또 번호를 생성한 다음 옵션 5 를 선택하여 생성한 번호에 대한 통계를 확인해 보십시오. 충분한 숫자를 생성하면 각 추첨이 무작위임에도 불구하고 어떤 숫자가 더 자주 나타나는지 확인할 수 있습니다.
통계 구현 이해
통계 모듈은 몇 가지 고급 Python 개념을 보여줍니다.
- 클래스 (Classes): 통계 기능을 캡슐화하기 위해 클래스를 사용했습니다.
- 데이터 구조 (Data Structures): 기록 (history) 에는 목록 (list) 을, 빈도 (frequency) 에는 딕셔너리 (dictionary) 를 사용합니다.
- 람다 함수 (Lambda Functions): 빈도별 정렬을 위해 정렬 함수에서 람다를 사용합니다.
- 리스트 슬라이싱 (List Slicing): 가장 최근 추첨을 얻기 위해 슬라이싱을 사용합니다.
통계는 로또 애플리케이션에 더 깊이와 유용성을 제공하여 간단한 개념 (난수 생성) 을 보다 완전한 애플리케이션으로 확장하는 방법을 보여줍니다.
이것으로 로또 번호 생성기 애플리케이션이 완료되었습니다. 다음 방법을 배웠습니다.
- Python 에서 난수를 생성합니다.
- 난수의 고유성을 보장합니다.
- 재사용 가능한 함수를 만듭니다.
- 사용자 인터페이스가 있는 완전한 애플리케이션을 구축합니다.
- 통계 및 기록을 추적합니다.
이러한 기술은 로또 번호 생성 외에도 다른 많은 프로그래밍 프로젝트에 적용할 수 있습니다.
요약
이 튜토리얼에서는 Python 을 사용하여 고유한 난수 로또 번호를 생성하는 방법을 배웠습니다. 난수 생성의 기본 사항부터 시작하여 통계 추적이 포함된 완전한 로또 애플리케이션을 갖출 때까지 점점 더 정교한 구성 요소를 구축했습니다.
다음은 수행한 작업입니다.
- Python 의
random모듈과 다양한 유형의 난수를 생성하는 방법을 배웠습니다. random.sample()을 사용하여 고유한 로또 번호를 생성했습니다.- 다양한 로또 형식에 대한 재사용 가능한 함수를 만들었습니다.
- 로또 애플리케이션을 위한 명령줄 인터페이스를 구축했습니다.
- 번호 빈도 및 기록을 분석하기 위해 통계 추적을 추가했습니다.
이러한 기술은 로또 번호 외에도 시뮬레이션, 게임 또는 제약 조건이 있는 무작위화가 필요한 모든 애플리케이션과 같은 다른 많은 프로그래밍 시나리오에 적용할 수 있습니다.
이제 Python 에서 난수 생성에 대한 탄탄한 기반을 갖추었으며 향후 프로그래밍 프로젝트에서 이러한 개념을 계속 구축할 수 있습니다.



