Skip to content

dtiberio/EuroMillionsSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I developed this EuroMillions Simulator Python program as a practice test while attending a Python training course.

It offers an opportunity to cover a variety of Python programming competencies:

  1. Control Flow Constructs:

    • For Loops: Utilized for iterating over sequences (like lists) or using a counter to execute a block of code multiple times, such as in the countdown timer (errorTimer function).
    • While Loops: Used to continuously execute a block of code as long as a certain condition remains true, evident in the main loop of the program that handles user inputs and game states.
  2. Conditional Statements:

    • If/Else Conditions: Fundamental for decision-making in the program, helping to check conditions and execute code accordingly.
    • Match Case (Switch Case): A newer Python feature (requires Python >=3.10) used for pattern matching against specific values, useful in handling different game states and user inputs more cleanly.
  3. Data Structures:

    • Lists: Essential for storing collections of items, such as user-selected numbers or randomly generated lottery numbers, and for handling these items using indices and loops.
    • Sorting and Searching: Demonstrated in managing and accessing list data, such as sorting lists or finding common elements between two lists.
  4. Functions:

    • Defining and Calling Functions: The program modularizes functionality into functions, which helps in organizing code, making it reusable and easier to manage.
    • Arguments and Return Values: Functions in the program often take parameters and return data, exemplifying how to pass data to and from functions.
  5. Error Handling:

    • Try and Except Blocks: Used to manage exceptions that may arise during runtime, particularly during input handling, which prevents the program from crashing due to invalid user input.
  6. Python Standard Libraries:

    • os and time Libraries: Used for performing operating system dependent functionality like clearing the terminal and implementing delays.
    • random Library: Essential for generating random numbers, a critical part of the lottery number selection process.
  7. External Libraries and Modules:

    • Using pip for Installing Libraries: The program requires external libraries, such as art and colorama for colored terminal output, demonstrating how to enhance Python's capabilities with additional modules.
    • Importing and Utilizing Modules: Shows how to import and use functions from both built-in and third-party libraries.
  8. User Input and Output:

    • Input Handling: Capturing and processing user input is a core part of the program, allowing interaction through the terminal.
    • Output Formatting: Demonstrates various ways to format and display information back to the user, including handling text color and style in the terminal.
  9. Best Practices:

    • Code Documentation: Through docstrings and comments, the program provides good examples of how to document Python code effectively, which is crucial for maintainability and readability.
    • Modular Design: Encourages the development of a modular coding approach, helping to keep code blocks small, manageable, and responsible for specific functionalities.

I share this code as-is in the hope that you might find it usefull for enhancing your Python programming skills.

To run the code, create a Python venv and then install the dependencies:

python -m venv venv

cd venv

.\venv\scripts\activate.bat

pip install -r requirements.txt

To start the program, run the Python script from your Windows terminal:

python euro_main_en.py

About

EuroMillions Simulator Python program

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages