This quiz must be submitted in Gradescope by 12:00pm CST on Tuesday, April 20, 2021.
This quiz covers HTML, CSS, and the basics of the Python web framework Flask.
Quizzes are INDIVIDUAL, closed book, and only allow access to specified resources. For this quiz you can access:
There are two problems on this quiz, numbered 2 and 3. The point breakdown is:
Points | Item |
---|---|
3 | autograder |
4 | problem 2 |
4 | problem 3 |
11 | total |
Write a Python program quiz13prob2.py
that takes a single command line argument, a positive integer n
, and which generates a HTML file that has a title, a header (h1), and contains an unordered list of the first n
perfect squares. It should save the output to a file called squares.html
.
For example, running
python3 quiz13prob2.py 5
should create a file squares.html
that when opened in a browser looks similar to the screenshot below.
Due to differences between browsers, a correct HTML file may look slightly different from this screenshot. (You don't need to use any CSS to achieve a more precise match.)
Also, browsers are often willing to render invalid HTML, so loading your HTML in a browser is not a perfect test of its correctness. Be sure to manually inspect the contents and check that each opening tag has a corresponding closing tag, for example.
Make a Flask application quiz13prob3.py
that has a single route, /
, which returns an HTML document whose body contains either
<h1 class="encouraging">Yes, it's Friday!</h1>
or
<h1 class="disappointing">No, it isn't Friday.</h1>
according to whether or not it is Friday at the time the request is served. Include an inline CSS stylesheet in the document header (in a <style>
tag) which ensures that "Yes, it's Friday!" will always appear in large green text while "No, it isn't Friday." will always appear in small red text. The same stylesheet should be included no matter what day of week it is; you must use the class
attributes of the h1
tags to ensure different syles are applied to the two possible messages.
Note: We haven't worked with Python's datetime
module very much in MCS 275, though it is often covered in MCS 260. For the purposes of this problem, it should be enough to know the following way to get the current day of week:
import datetime
datetime.datetime.now().weekday() # returns an integer, 0=Mon, 1=Tue ..., 4=Fri, 5=Sat, 6=Sun