An interactive textbook teaching basic concepts of computer science and programming.
This project is maintained by brendanpshea
PyQuiz is an interactive Python coding practice tool designed to help students learn and practice Python programming through a series of coding questions. It provides a user-friendly interface using IPython widgets, making it ideal for use in Jupyter notebooks or similar interactive Python environments.
Install the required dependencies:
pip install ipywidgets pandas numpy
Download the pyquiz.py
file from the GitHub repository:
wget https://github.com/brendanpshea/computing_concepts_python/raw/main/python_code_quiz/pyquiz.py
In your Jupyter notebook or interactive Python environment, import the PracticeTool
class:
from pyquiz import PracticeTool
Create an instance of the PracticeTool
class, specifying the path to your JSON file containing the questions:
practice_tool = PracticeTool(json_url='path_to_your_questions.json')
You can also use a URL to load questions from a remote source:
practice_tool = PracticeTool(json_url='https://example.com/questions.json')
The tool will automatically display and allow interaction with the coding questions.
To create your own set of questions, prepare a JSON file in the following format:
{
"questions": [
{
"function_name": "example_function",
"parameters": ["param1", "param2"],
"description": "Write a function that does X",
"input_type": ["int", "string"],
"answer_code": "def example_function(param1, param2):\n # Correct implementation here\n return result",
"hint": "Consider using method Y",
"test_inputs": [[1, "a"], [2, "b"]]
},
// Add more questions here
]
}
function_name
: The name of the function to be implementedparameters
: List of parameter names for the functiondescription
: A description of what the function should doinput_type
: Types of inputs for each parameter (can be a single string for all parameters)answer_code
: The correct implementation of the functionhint
(optional): A hint to help students if they get stucktest_inputs
(optional): Custom test inputs for the functionContributions to improve PyQuiz are welcome. Please feel free to submit pull requests or open issues on the GitHub repository.
This project is open source and available under the MIT License.