Skip to content

This is a Flask-based web application designed to help users practice and improve their Python programming skills.

Notifications You must be signed in to change notification settings

dustinwloring1988/python-learning-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python Learning Game

This is a Flask-based web application designed to help users practice and improve their Python programming skills. The application presents users with various coding challenges of different difficulty levels and allows them to write and run their code directly in the browser.

Features

  • Difficulty Levels: Challenges are categorized into easy, medium, and hard levels.
  • Code Editor: Integrated code editor using CodeMirror.
  • Instant Feedback: Users can run their code and see how many tests they passed.
  • Solutions: View solutions for completed challenges.

Folder Structure

python-learning-game/
├── app.py
└── challenges/
    ├── easy.yaml
    ├── medium.yaml
    └── hard.yaml
└── templates/
    ├── index.html
    └── challenge.html

How to Run

  1. Clone the Repository:

    git clone https://github.com/dustinwloring1988/python-learning-game.git
    cd python-learning-game
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run the Application:

    python app.py
  4. Access the Application: Open your web browser and go to http://127.0.0.1:5000.

Adding New Challenges

To add new challenges, follow these steps:

  1. Open the Appropriate YAML File: Challenges are stored in YAML files within the challenges folder (easy.yaml, medium.yaml, hard.yaml).

  2. Add a New Challenge: Use the following structure to add a new challenge:

    - title: Challenge Title
      difficulty: easy|medium|hard
      description: "Write a function called 'function_name' that does something."
      example: "Example: function_name(input) should return output."
      template: |
        def function_name(params):
            # Write your code here
            pass
      solution: |
        def function_name(params):
            # Correct solution code
            return result
      tests:
        - input: 'function_name(test_input)'
          expected: expected_output
        - input: 'function_name(another_test_input)'
          expected: another_expected_output
  3. Save and Test: After adding the new challenge, save the YAML file and restart the application to load the new challenges.

Example Challenge

Here is an example of an easy challenge:

- title: Reverse String
  difficulty: easy
  description: "Write a function called 'reverse_string' that returns the reverse of a given string `s`."
  example: "Example: reverse_string('hello') should return 'olleh'."
  template: |
    def reverse_string(s):
        # Write your code here
        pass
  solution: |
    def reverse_string(s):
        return s[::-1]
  tests:
    - input: 'reverse_string("hello")'
      expected: 'olleh'
    - input: 'reverse_string("world")'
      expected: 'dlrow'
    - input: 'reverse_string("Python")'
      expected: 'nohtyP'

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

This is a Flask-based web application designed to help users practice and improve their Python programming skills.

Topics

Resources

Stars

Watchers

Forks

Packages