This shows you the differences between two versions of the page.
ii:labs:s2:01:tasks:02 [2022/03/31 18:53] florin.stancu created |
ii:labs:s2:01:tasks:02 [2024/03/15 13:30] (current) florin.stancu [02. [20p] Let's do the math!] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 02. Integration with Flask backend ==== | + | ==== 02. [25p] Let's do the math! ==== |
- | We now want to move the design from a static ''html'' file to using Flask Jinja template rendering. | + | Python is also popular for its numeric manipulation features (it can handle very large numbers!). |
- | For this, you must: | + | Let's find out: |
- | + | ||
- | * Migrate / split the HTML code to ''templates/_base.html'' and ''templates/index.html'' | + | |
- | * //Note:// use Jinja2 [[https://jinja.palletsprojects.com/en/3.1.x/templates/#template-inheritance|template inheritance]] with an empty content block; | + | |
- | * Modify ''server.py'' to call ''render_template'' to actually serve our design. | + | |
- | * Also create ''about.html'' and a Python method for serving it (fill it with whatever content you want ;) ). | + | |
+ | * Read a number from the console (you should know how to do it by now; don't forget to convert it to an ''int''!); | ||
+ | * Reverse the number's digits and print the result (e.g., ''13568 => 86531'')! | ||
+ | * Define a new function, ''generate_prime(k)'', which takes in an argument and will generate a prime number of exactly ''k'' digits; use it to generate a 15-digit prime number (decrease this if it's taking too long '':('' )! | ||