List above contains 26 fruits each one with a name that


List of fruits:

papaya

kiwifruit

zapote blanco

huckleberry

banana

fig

lime

xigua

vanilla

yiessas

tamarind

umkolo

quince

apple

imbu

elderberry

juneberry

mango

strawberry

nectarine

date

cherry

orange

watermelon

grape

raspberry

List above contains 26 fruits, each one with a name that begins with a different letter of the alphabet.

Make program named sort_fruits.py that reads in the fruits from the file unsorted_fruits.txt and writes them out in alphabetical order to a file named sorted_fruits.txt.

Incorporate the use of a list, for loop and / or while loop.

Create either pseudo code or a flowchart of your program. Your model must show how your program will read the input file, sort the entries and generate the output file.

In addition, you must submit both your program source code sort_fruits.py as well as the sorted file sorted_fruits.txt.

You can use the following fragment of code the open and read in the data from the unsorted_fruits.txt file. You will need to determine how to use a list structure to sort the items and how to write the data back out into the sorted_fruits.txt file.

infile = open("unsorted_fruits.tex", "r")

outfile=open("sorted_fruits.txt","w")

fruit=infile.read(50)

outfile.write(fruit)

print (fruit)

infile.close()

outfile.close()

In using this code fragment, once you have read a line from the file into the variable text, you must then determine how to load it into a list structure.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: List above contains 26 fruits each one with a name that
Reference No:- TGS02941358

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)