Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 Task marks
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 PCs working directory or the folder The file is available in Programming Assignment instructions and submission section.
You need to read the data from the input file named as inputfile The data consists of multiplechoice 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 newfile.
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
ssignmenCSEIPSumipynb
Code Text
You snoula ranaomiy reoraer tne cnoices tor eacn question.
You should write the reordered data into a new file, named as newfile.
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 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started