Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What would be a good pseudocode for this code? file = open(\'C:\\Python34\\unsor

ID: 3601450 • Letter: W

Question

What would be a good pseudocode for this code?

file = open('C:Python34unsorted_fruits.txt','r')
outfile=open('C:Python34sorted_fruits.txt','w')

#readlines return a list
fruits=file.readlines()

#list.sort() do an inline sort
fruits.sort()

#remove the blank lines and write the file
for fruit in fruits:
if fruit != ' ': #if fruit is blank, skip the write
outfile.write(fruits) #otherwise write the fruit to the output file
outfile.write(" ")
  
#close the input and output file
file.close()
outfile.close()
  

Explanation / Answer

For this code pseudo code is a real thing, as everything is too abstract, with calling functions.
Anyways, a pseudo-code is writing the code in more human-readable manner, than in computer
language syntactic manner. Its prettymuch like algorithm.
This code is related to python.
Here is the pseudo-code for you:

1. file <- Open an input file stream for file "unsorted_fruits.txt"
2. outfile <- Open an output file stream for file "sorted_fruits.txt"
3. fruits <- Read all lines from file.
4. Sort fruits.
5. for each value fruit in fruits:
   5.1 if fruit ~= ' '
           Write fruit to outfile.
           Write a newline to outfile.
6. close file.
7. close outfile.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote