anybody familiar with python

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

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
Files:
?
?
?
?
?
Create your own python file with our convention (userID_2xx_L11.py).
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 tester11L.py gmason76_2B5_L11.py 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.
Tasks
?
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
in.txt
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”)
?[1,3]
3 Will is up hill still
o locate (“in.txt”,”ill”)
?[1,2,3]
4
o locate (“in.txt”,”will”) ?[]
5
6
?
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
out.txt
should be overwritten; (2) dictionary d could be empty; (3) the
value list could be empty; and (4) the function returns None.
apple:
2
orange:
1,
3
? 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)
———————————-TOTAL:
100
f1.txt
before
100
100
3
100
9
9
f1.txt
after
100
100
3
100
9
9
Sum:321

Purchase answer to see full
attachment

Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency

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