Home>

I am making a program that generates exam problems unique for each student. The problem arises when you need to print it all on paper. How can I create a document through python that will contain the tasks that I generated? Is there something other than html and latex?

Excuse me, what did html and latex displease you?

andreymal2021-11-26 03:09:11

You can docx create python-docx.readthedocs.io/en/latest

Andy Pavlov2021-11-26 03:09:11
  • Answer # 1

    You can save the generated formulas as a picture. I am attaching a sample code:

    import random
    import matplotlib as plt
    b= random.randint (2, 4)
    c= random.randint (2, 4)
    n= random.randint (2, 4)
    x= b ** c-n
    formula= f '$ \ log_ {b} (x + {n})= {c} $'
    xsize= 5
    ysize= 1.5
    plt.figure (figsize= (xsize, ysize))
    plt.text (0.0, 0, formula, fontsize= 35)
    # Hide the axes
    plt.axis ('off')
    plt.savefig ('filename.png')
    plt.close ()
    

    Correct import import matplotlib.pyplot as plt, and how you get the error.

    CrazyElf2021-11-26 03:09:11
  • Answer # 2

    I think what you are looking for is PyFPDF... Is PDF good for printing?

    What can:

    1. Various fonts
    2. Customizing pages (portrait, landscape, A4, A5, letter, etc.)
    3. Insert pictures
    4. Styling and customizing footers, headers
    5. Graphs (justplotcan be sent), pictures
    6. Working with. That is, you can simply insert your HTML in triple quotes and you should be fine. Just don't forget about the support for tags, everything is in the documentation. For example, the tag< img >supported along with dimension and source attributes
    7. and much more

    And for a more detailed analysis, give examples of your tickets.