Question: File Edit View Insert Runtime Tools Help All changes saved : = , + Code + Text Q , v v Task 2 ( 3

File Edit View Insert Runtime Tools Help All changes saved
:=,+ Code + Text
Q ,vv Task 2(30 marks)
{x}, For this task, you are to write a simple program to read data from a text file, save data in a dictionary data structure, reorder the data, and then write the reordered data into a new file.
Instructions
Download the input file.txt file into your PC's working directory (or the folder). The file is available in Programming Assignment 2(instructions and submission) section.
You need to read the data from the input file (named as input_file). The data consists of multiple-choice questions.
You Must save data in a dictionary data structure
You should randomly reorder the choices for each question.
You should write the reordered data into a new file, named as new_file.
For example, the first question in the input file is
What is the capital of Australia?, (a) Canberra, (b) Perth, (c) Sydney,(d) Melbourne.
And here is what it might look like, for example, after reordering the choices for each question
What is the capital city of Australia?
(a) Sydney
(b) Melbourne
(c) Perth
(d) Canherra
___ssignmen_CSE4IP_2_Sum_2023.ipynb
Code + Text
You snoula ranaomiy reoraer tne cnoices tor eacn question.
You should write the reordered data into a new file, named as new_file.
For example, the first question in the input file is
What is the capital of Australia?, (a) Canberra, (b) Perth, (c) Sydney,(d) Melbourne.
And here is what it might look like, for example, after reordering the choices for each question
What is the capital city of Australia?
(a) Sydney
(b) Melbourne
(c) Perth
(d) Canberra
Requirements
To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:
You must NOT change the format of the input file or the output file.
You must use dictionary data structure.
Your program must ready any file with any number of questions. The given file contains 4 questions only, but the program should read any file and reorder the choices regardless of the number of questions.
You must handle the situation if the file does not exist.
 File Edit View Insert Runtime Tools Help All changes saved :=,+

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!