First assignment¶
Write the code for a simple book (pdf).
Send me this code until 07.12.
No worries, you don’t have to spend a lot of time with it, it’s just an exercise for you to write some code.
To limit you (and your amount of work), the code is constrained to the elements we’ve learned so far. (So you can’t use anything of Python or FPDF that we haven’t used already.)
# variables of type int, float, str
# overriding variables
# simple mathematical operations
+
-
/
*
# casting of data types
int()
float()
str()
# lists
# like
advent_calendar = ['apple', 'beer', 'cherry', 'date']
# for loops
# like
for i in range(2, 11):
print(i)
# or
for item in advent_calendar:
print(item)
And of course the FPDF library and the code we’ve written in the chapters “First book” and “Programmed books 2”.
FPDF() # the object itself
# the following methods
.add_page()
.ln()
.multi_cell()
.set_font()
.set_font_size()
.set_margins()
.set_text_color()
.output()
Help pages for FPDF: