Starting from:

$30

Quiz 4 Collections & File I/O


BBM 103: Introduction to Programming Laboratory I
Quiz 4
Subject: Collections & File I/O

Introduction
Within the context of this quiz, you are going to gain experience on using different
collections (dictionary, list and their functions) as well as on using File I \O. The scenario of
this work is receiving a message which is split into multiple packets and transferred over the
Internet. Packets are not received in order in which they are sent.
Your program must read the input file, sort the packets and write the completed messages
to an output file. You will not print output to terminal, you just have to write it into
output file which is given as system argument (outputFile.txt).
As you see from the input format, each line of input represents a single packet. each line is
formatted as given below:
X (tab) Y (tab) message part
X represents message ID, Y represents packet ID. It is guaranteed that there will be no
duplicate packets or message IDs.
Example Input:
Figure 1: An example of input file
1
Fall 2021
BBM 103: Introduction to Programming Laboratory I
As you see from the output format, each line is formatted as given below:
Message (tab) number
X (tab) Y (tab) message part
(number denotes 1,2,3,etc.)
Example Output:
Figure 2: An example of output file
The order of command-line arguments should be provided as follows:
python3 quiz4.py inputFile.txt outputFile.txt
P.S. The name of the input file and output file will be ”inputFile.txt” and ”outputFile.txt”,
respectively. Compilation problems caused by incorrect filenames are at your own
responsibility. Please, be careful about it.
Notes
• Do not miss the submission deadline! Use the submit system. Submissions as e-mail
attachments will not be accepted.
• Test your code with the input and respective output files prior to submission on dev
server.
• Save all your work until the quiz is graded.
• You can ask your questions via Piazza and you are supposed to be aware of everything
discussed on Piazza.
2
Fall 2021
BBM 103: Introduction to Programming Laboratory I
• You must submit your work (must be ”quiz4.py”) with the file hierarchy as stated
below. You will just zip your quiz4.py file and submit this zip file. Please do not create
a new folder, do not put your quiz4.py file inside this folder, and do not zip this folder!
→ <quiz4.py>
3