Answered step by step
Verified Expert Solution
Link Copied!

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 ,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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

denigration of emotional outbursts; being reserved;

Answered: 1 week ago