Binary Files · 10 / 14 Exercise Medium

File splitter

Objective

Create a Python program that divides text or binary files into parts of 5 Kb each. Open the files in binary mode to read the original file and write the different parts. Use the format name-01 to name each part of the file.

Files: the file data.bin already exists. Split it into parts of 5 Kb (5120 bytes) each, the last one can be smaller. Name the parts data-01, data-02, data-03… (the name without extension, a hyphen and the part number with two digits). Use binary mode. The program must not print anything.

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise