Pseudo code or a flowchart of program

Assignment Help Basic Computer Science
Reference no: EM131507225

The file unsorted_fruits.txt (which is available in the resources section of this unit in the resources section) contains a list of 26 fruits, each one with a name that begins with a different letter of the alphabet.

Write a 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.

For this assignment you must incorporate the use of a list, for loop and / or while loop.

For this assignment you must create either pseudo code or a flowchart of your program and attach it along with your assignment submission. You 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 with your assignment.

The following sections within the downloadable .pdf version of the textbook contain examples of Python code that you can use to complete this assignment.

  • Section 10 Sorting
  • Section 14.2 Reading and writing files
  • Section 14.4 Filenames and paths

Similar examples can be found in the interactive version of the textbook as follows:

  • Section 10 Lists
  • Section 11.3 Reading Files
  • Section 11.6 Writing Text Files
  • Section 11.2 Finding a File on your Disk 

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. 

Also keep in mind that you may need to include the directory path when opening files so this may need to be included in your open statement.

The following web site references might come in handy. 

This provides an example of reading and writing text files in python: 

https://www.dreamincode.net/forums/topic/198139-reading-and-writing-to-a-txt-file-in-python/

This video provides an example of reading data from a file and loading it into a list structure and sorting the list. 

https://youtu.be/JA4neapsdqQ

This site has an example of how to sort a list structure. https://effbot.org/zone/python-list.htm

Similar examples can be found in the interactive version of the textbook as follows:

  •   Section 10 Lists
  •   Section 11.3 Reading Files
  •   Section 11.6 Writing Text Files
  •   Section 11.2 Finding a File on your Disk 

Assignment rubric 

  • Does the assignment read the input file, sort the items in the file and write the sorted list in the correct order to the output file (You can determine this by looking at the contents of the output file that should be attached with the submission)?
  • Did the assignment include either pseudo code or a flowchart that outlines the conceptual model of the program detailing its operation and flow?
  • Did the assignment include the use of the python list structure and either the for loop and/or the while loop?
  • Did the assignment include comments and descriptive variables?

Reference no: EM131507225

Questions Cloud

What is the company current weighted average cost of capital : The preferred stock is trading at $105. What is the company’s current weighted average cost of capital?
Prepare an analysis that will aid the budget director : A hospital administrator is faced with the problem of having a limited amount of funds available for capital projects. He has narrowed his choice down to two.
Define test driven development : Define Test Driven Development (TDD) and discuss the advantages (and potential disadvantages) of using test-driven development.
Create a brief overview of the company requirements : Create a brief overview of the company requirements for a total rewards system.Formulate a total rewards strategy to encompass the fundamentals.
Pseudo code or a flowchart of program : For this assignment you must create either pseudo code or a flowchart of your program and attach it along with your assignment submission.
Do you consider the project economically acceptable : A potential project has an initial capital investment of $100,000. Net annual revenues minus expenses are estimated to be $40,000 (A$) in the first year.
What is the operating cash flow for this project : what is the Operating Cash Flow for this project?
What is standard deviation of these returns : What is the standard deviation of these returns?
Ethical practices for cybersecurity investments-purchases : You have been invited to participate in a "lightning round" panel on the above topic at a conference on Best Practices for IT Security Management.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd