38 lines
1.3 KiB
Markdown
38 lines
1.3 KiB
Markdown
# Brain Jogging PDF Generator
|
|
|
|
This Python script generates a brain jogging PDF with math problems. The PDF contains 20 rows with 4 math problems per row, chosen randomly from addition, subtraction, multiplication, and division. The PDF has two pages: the first page contains only the math problems, and the second page includes the problems along with their results.
|
|
|
|
## Dependencies
|
|
|
|
- Python 3
|
|
- reportlab
|
|
- argparse
|
|
|
|
You can prepare the environment and install the reportlab library using pip:
|
|
```
|
|
python -m venv env
|
|
source env/bin/activate
|
|
python -m pip install --upgrade pip
|
|
pip install reportlab
|
|
```
|
|
|
|
## Usage
|
|
|
|
You can run the script from the command line:
|
|
```
|
|
python brain-jogging.py [filename]
|
|
```
|
|
|
|
## Functions
|
|
|
|
The script contains the following functions:
|
|
|
|
- `format_and_return(a, b, operation, result)`: Formats and returns a math problem string along with its result.
|
|
- `generate_math_problem()`: Generates a random math problem with an operation chosen from addition, subtraction, multiplication, or division.
|
|
- `create_brain_jogging_pdf(filename)`: Creates a brain jogging PDF with math problems and saves it to the specified filename.
|
|
- `main()`: The main function that parses command-line arguments and calls the `create_brain_jogging_pdf()` function with the provided arguments.
|
|
|
|
|
|
## License
|
|
|
|
This script is available under the MIT License. |