Creates python worksheets with random recursive functions from the book "The Recursive Book of Recursion" by Al Sweigart along with a pytest test file to check answers.
Inside of the RecursionWorksheet folder in the terminal you can run the command
python main.py make -n 3
This will create a worksheet in the worksheets\mm-dd\worksheet.py with three random recursive algorithms for the user to fill out.
Once you are done finishing writing the algorithms, you can test them by running the command:
python main.py test
The terminal will print the pytest results
- python
- pytest
-
Download or clone repository on your computer via the green <> Code dropdown menu.
-
pip install pytest inside of virtual environment
pip install pytest
-
Inside of the RecursionWorksheet directory in the terminal or command line run the following code to create a new worksheet with 10 different algorithms.
python main.py make -n 10
-
Inside of the worksheet/mm-dd folder there should be two new files:
- worksheet.py
- test_worksheet.py
-
The worksheet.py file will have the the functions defined with a short description detailing what algorithm the function should complete.
-
Once you are done writing out the answers you can test your worksheet by running the following command
python main.py test
There program has four different commands. If you try to run the main.py script without one of these four commands then the program will return with an error message.
-
make - Creates a new worksheet.py file inside of the worksheet/MM-DD directory along with a test_worksheet.py file used to test.
-
test - Runs pytest and prints results to the terminal.
-
clean - Removes all of the tests inside of the worksheets/ directory
-
remove - Removes one worksheet
There are two optional command line arguments. If you don't include these the program will assume the default values.
-
-n - Specify the number of worksheets to create. The default is set at 5. "make" is the only command that uses the -n command.
-
-d - Specify the date (or what you want to name the folder). The default is set at the current date.
python main.py make -n 7
python main.py test -d 12-11
python main.py make -n 3 -d i_love_corgis
python main.py test -d i_love_corgis
python main.py remove -d i_love_corgis
python main.py clean