CS160 Lab 4 Formatting and File I/O Solved

35.00 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (1 vote)

Create a file named chaos.py that solves Programming Exercise 11 on pp. 163-164 with the change that instead of printing to the screen, it sends the output to a file named output.txt. Your program must ask you to enter two numbers (between 0 and 1) separated by a comma (i.e., use one input function call) and then the table output must be sent to the file output.txt and match the sample formatting exactly as it is in the book. Count the dashes (they are minus signs, not underscores in your output) and have everything line up at the same columns as it does. Below is a same run.

enter x1 and x2 separated by a comma: 0.34, 0.35

And then the file output.txt contains:

index           0.34                    0.35


1                0.875160 0.887250

2                0.426094 0.390146

3                0.953698 0.927935

4                0.172216 0.260799

5                0.555976 0.751853

6                0.962780 0.727624

7                0.139755 0.772931

8                0.468872 0.684484

9                0.971221 0.842266

10             0.109008 0.518130

Create a file named acronym.py that solves Programming Exercise 10 on p. 198. You must have a main function that calls the acronym function. Your acronym function must take as one parameter the string and return a string which is the acronym for the string that is passed as the parameter. Your acronym function must not have any input or print function calls. Below is a sample run.

enter phrase: random access memory RAM

Each file should have a function named main with all the code and then call the main function at the bottom of the file. Follow the style of my solutions to the previous labs. Review the lab grading rubric on iLearn to make certain you meet all the specifications.

Remember to put your name, course, and time in comments at the top of each file and comment your code. Using Capital’s webmail, email me a message with the subject CS160-1ATT for 1PM or CS160-2ATT for 2PM with your chaos.py, acronym.py, and help.txt files attached.


  • Lab-4-acronym-chaos.zip