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.
- Difficulty Levels: Challenges are categorized into
easy
,medium
, andhard
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.
python-learning-game/
├── app.py
└── challenges/
├── easy.yaml
├── medium.yaml
└── hard.yaml
└── templates/
├── index.html
└── challenge.html
-
Clone the Repository:
git clone https://github.com/dustinwloring1988/python-learning-game.git cd python-learning-game
-
Install Dependencies:
pip install -r requirements.txt
-
Run the Application:
python app.py
-
Access the Application: Open your web browser and go to
http://127.0.0.1:5000
.
To add new challenges, follow these steps:
-
Open the Appropriate YAML File: Challenges are stored in YAML files within the
challenges
folder (easy.yaml
,medium.yaml
,hard.yaml
). -
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
-
Save and Test: After adding the new challenge, save the YAML file and restart the application to load the new challenges.
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'
This project is licensed under the MIT License. See the LICENSE file for more details.