Please, give me the Python code to join two PDF files.
Here is an example of Python code that uses the PyPDF2 library to join two PDF files:

import PyPDF2

# Open the first PDF file
pdf1 = open(file1.pdf, rb)
pdf1_reader = PyPDF2.PdfFileReader(pdf1)

# Open the second PDF file
pdf2 = open(file2.pdf, rb)
pdf2_reader = PyPDF2.PdfFileReader(pdf2)

# Create a new PDF file to hold the combined pages
pdf_writer = PyPDF2.PdfFileWriter()

# Add all the pages from the first PDF file
for page in range(pdf1_reader.numPages):
    pdf_writer.addPage(pdf1_reader.getPage(page))

# Add all the pages from the second PDF file
for page in range(pdf2_reader.numPages):
    pdf_writer.addPage(pdf2_reader.getPage(page))

# Save the combined PDF file
with open(combined.pdf, wb) as output:
    pdf_writer.write(output)

# Close the PDF files
pdf1.close()
pdf2.close()

This code first opens two PDF files, file1.pdf and file2.pdf, using the open function and the PdfFileReader class from the PyPDF2 library. It then creates a new PdfFileWriter object to hold the combined pages. The code then loops through all the pages in each PDF file, adding them to the new pdf_writer object. Finally, the code saves the combined PDF file as combined.pdf and closes the original PDF files.

Note: Make sure you have PyPDF2 installed in your system before running this code. If not, install it by running pip install PyPDF2.
Ok, now give me the same code, but print on screen the weight of the final PDF file
Sure, here's the code you asked for:
import PyPDF2
import os

# Open the first PDF file
pdf1 = PyPDF2.PdfFileReader(open(file1.pdf, rb))

# Open the second PDF file
pdf2 = PyPDF2.PdfFileReader(open(file2.pdf, rb))

# Create a new PDF file
pdf_writer = PyPDF2.PdfFileWriter()

# Add pages from the first PDF
for page in range(pdf1.getNumPages()):
    pdf_writer.addPage(pdf1.getPage(page))

# Add pages from the second PDF
for page in range(pdf2.getNumPages()):
    pdf_writer.addPage(pdf2.getPage(page))

# Save the final PDF
with open(final.pdf, wb) as file:
    pdf_writer.write(file)

# Print the size of the final PDF file
file_size = os.path.getsize(final.pdf)
print(Final PDF file size:, file_size, bytes)

I hope it's useful for you, if you have more questions about how to write certain code, tell me!