Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROGRAM: read from txt file and output men0.txt m1;w3;w2;w1 m2;w3;w1;w2 m3;w2;w1;w3 women0.txt w1;m1;m2;m3 w2;m2;m1;m3 w3;m3;m2;m1 Read files of men and women and their rankings

PYTHON PROGRAM: read from txt file and output

image text in transcribed

image text in transcribed

men0.txt

m1;w3;w2;w1 m2;w3;w1;w2 m3;w2;w1;w3

women0.txt

w1;m1;m2;m3 w2;m2;m1;m3 w3;m3;m2;m1

Read files of men and women and their rankings of all members of the opposite gender (highest to lowest preference), separated by semicolons, building a dictionary like the ones above (where each match is initially the special value None). As described above, we annotate the structure of this dictionary as {str:[str,[str) In the file, the person's name appears first, followed by the names of all members of the opposite gender in highest to lowest preference, separated by one semicolon character. For example, the input file men0.txt contains the following lines: these line could appear in this order, or any other, but the each man's preferences must appear in decleasing order of preference The first line means, ml ranks the members of the opposite gender in the order of preference from w3, w2, and wl in decreasing order of preference Each line is guaranteed to start with a unique name, which is guaranteed to be followed by all the names of all members of the opposite gender, each appearing once; and all names are separated by semicolons When you print such information, print each person on a separate line, followed by his/her match and preferences. For example, the file above would print as m1 - [None, ['w3', W2', m2 [None, ['w3' m3[None, ['w2', 'i', w3']] Note that the names on the lines must be sorted in alphabetical order, the list of preferences must appear in the same order they appeared in the file. There are multiple pairs of data files for this program, all named like men0.txt and women0.txt; Test/debug your program on the first file; when you are done, test it on the remaining files

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions