Added documentation for create_brain_jogging_pdf function

This commit is contained in:
Heiko J Schick
2023-03-23 21:01:18 +01:00
parent 9166ab5049
commit 1ac8db58f7
+22
View File
@@ -51,6 +51,28 @@ def generate_math_problem():
return format_and_return(a, b, operation, a // b)
def create_brain_jogging_pdf(filename):
"""
Creates a brain jogging PDF with math problems and saves it to the specified filename.
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.
Args:
filename (str): The output PDF filename.
Dependencies:
- reportlab.lib.pagesizes.A4
- reportlab.platypus.SimpleDocTemplate
- reportlab.platypus.Paragraph
- reportlab.platypus.Spacer
- reportlab.platypus.Table
- reportlab.platypus.PageBreak
- reportlab.lib.colors
- reportlab.platypus.TableStyle
- reportlab.lib.styles.getSampleStyleSheet
- reportlab.pdfbase.pdfmetrics
- reportlab.pdfbase.ttfonts.TTFont
"""
problems = [[generate_math_problem() for _ in range(4)] for _ in range(20)]
data = [[problem[0] for problem in row] for row in problems]
data_with_results = [[f"{problem[0]} {problem[1]}" for problem in row] for row in problems]