anybody familiar with python

all info is in the file below. thank you ……… . .

Unformatted Attachment Preview

Don't use plagiarized sources. Get Your Custom Essay on
anybody familiar with python
Just from $13/Page
Order Essay

CS 112, Lab 11 – Exercise – File I/O
Due: Saturday, April 14th, 11:59pm
Create your own python file with our convention (
You should also download from Piazza a zipped file for testing, which includes the tester and some
example input/output text files
Extract the zipped file into the directory where your .py file is located
Run the tester as always: python3 just these funcs
Caution: do not change the .txt files from the zipped file. Re-download if necessary.
As this is an Exercise, you can read any and all materials, ask us questions, talk with other students, and
learn however you best learn in order to solve the task. Just create your own solution from those
experiences, and turn in your work.
Files provide convenience to deal with a large volume of data. They also serve as the long-term storage of
data that can be accessed by multiple programs or users.
We will solve some problems involving file I/O. Keep in mind that text files we will deal with can be
viewed as a Python string stored on disk. String values and methods are usually helpful in dealing with
file I/O.
Turning It In
Add a comment at the top of the file that indicates your name, userID, G#, lab section, a description of
your collaboration partners, as well as any other details you feel like sharing. Please also mention what
was most helpful for you. Once you are done, run the testing script once more to make sure you didn’t
break things while adding these comments. If all is well, go ahead and turn in just your one .py file you’ve
been working on over on BlackBoard to the correct lab assignment. We have our own copy of the testing
file that we’ll use, so please don’t turn that in (or any other extra files), as it will just slow us down.
What can I use?
You CANNOT import any modules. There are no further restrictions on what functions to use on this lab
– use this time to learn how to read, write, and/or append files.
def locate(filename,s): Given a string filename and a string s to search for in the file, return
an ordered list of all line numbers corresponding to the lines containing at least one occurrence of
the string s (case sensitive).
o Assumptions: (1) file indicated by filename exists in the current directory; (2) file can be
empty; (3) line number starts with 1; and (4) s is a non-empty string that does
not span more than a single line.
o Hint: in can be used to check for substrings
1 hill Will Will went up hill
? Examples given the file to the right:
2 Will hill still
o locate (“in.txt”,”up”)
3 Will is up hill still
o locate (“in.txt”,”ill”)
o locate (“in.txt”,”will”) ?[]
def store(d,filename): Given a dictionary d and a string filename, create a new file named
filename and output the content of d into that file. You can assume that the dictionary d always
has the key:value format as string:[list,of,integers]. Every key-value pair of the dictionary
should be output as: a string that starts with key, followed by “:”, a tab, then the integers from the
value list. Every integer should be followed by a “,” and a tab except for the very last one, which
should be followed by a newline. Multiple items of the dictionary must be sorted asciibetically by
their keys. See the example below.
o Assumptions: (1) if a file named filename already exists, then the content
should be overwritten; (2) dictionary d could be empty; (3) the
value list could be empty; and (4) the function returns None.
? Examples:
o d = {‘orange’:[1,3],’apple’:[2]}
o store(d,”out.txt”) should end up with a file to the right
# the file contents should be read as this string:
# “apple:t2norange:t1,t3n”
def append_total(filename): Given a string filename of a file containing
one integers (one per line), calculate the total of all the integers and append
the line “Sum:” followed immediately by the integer total (no spaces in
between) and ending with a newline. See example.
o Assumptions: (1) file indicated by filename exists in the current
directory; (2) file can be empty, and if so the sum will be 0; (3) a
non-empty file can contain one or more lines ending with a
newline; (4) each line contains a single integer and nothing else,
and (5) the function returns None.
? Examples:
o append_total(“f1.txt”) corresponds to the files to the right
Grading Rubric
Pass shared test cases
5×20 (zero points for hard-coding)

Purchase answer to see full

Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.


Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.


Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.


Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.


Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

Order your essay today and save 15% with the discount code DISCOUNT15