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

  Serial data transmission system

A serial data transmission system uses 1 start bit, 1 stop bit and 1 parity bit and 7 data bits per character. If the maximum character transmission rate is ten characters per second, Determine:

  How much should the company in detroit pay

An executive who makes $90,000 a year in Dallas has received an offer to do similar work for a company in Detroit. The new company has agreed to compensate her for the differences in consumer price index, between Dallas and Detroit. Assume that CPI i..

  Modify the hash.java program to use quadratic probing

Implement a linear probe hash table that stores strings. You'll need a hash function that converts a string to an index number; see the section "Hashing Strings" in this chapter. Assume the strings will be lowercase words, so 26 characters will su..

  Re-transmission or error correction

As you all know voice is fundamentally different from data. When a data packet is delayed, or corrupted, often the error is completely recoverable through re-transmission or error correction. What happens when a voice data packet is corrupted?

  What type of data model you are developing

Provide a brief description about what type of data model you're developing, along with a project description.

  Work experience during internship

In a 2-3 page paper, reflect on your work experience during this internship, and relate your experience to the learning and the readings

  Identify a firm with an it budgeting process

Assignment 1: Identify a firm with an IT budgeting process you are familiar with. Using the material in the text and that from your external research, write a paper in which you re-engineer the firm's budget process. You are required to briefly de..

  What are the independent and dependent variables

Look at the results of engineering analyses in journals or textbooks. What are the independent and dependent variables? Can a dependent variable be the independent variable in another experiment, and vice versa?

  Modes that combine encryption and authentication

Research paper choose one of block cipher modes of operation designed to achieve both message privacy and authentication, by merging the features.

  What is the impact on the end date of the project

If the customer offered you a bonus for completing the project in sixteen weeks or less, which activities would you focus on first as part of compression ("crashing") analyses?

  The design process ensure a good design

The design process ensure a good design.

  Formulate the lpp and solve it using the graphical method

The company makes a profit of $5 on X and $7 on Y. Assume that whatever is produced gets sold in the market. Formulate the LPP and solve it using the graphical method.

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