please answer in python coding
L10-5) (10 points)
Write a program that reads in the contents of the file
psalm112.txt and writes a new file
psalm112Upper.txt where all the characters are in
uppercase, e.g.
If psalm112.txt contains:
1 Praise the LORD.
Blessed are those who fear the
LORD,
who find great delight in his
commands.
2 Their children will be mighty in the
land;
the generation of the upright will be
blessed.
...
psalm112Upper.txt will contain:
1 PRAISE THE LORD.
BLESSED ARE THOSE WHO FEAR THE
LORD,
WHO FIND GREAT DELIGHT IN HIS
COMMANDS.
2 THEIR CHILDREN WILL BE MIGHTY IN THE
LAND;
THE GENERATION OF THE UPRIGHT WILL BE
BLESSED.
...
L10-6) (20 points)
Write a program that reads in a file (you could use
psalm112.txt) and then prints out the number of
lines, number of words, and number of characters in the file.
L10-7) (30 points)
Write a program that creates a concordance file - an index that
tells you on which line of the file each word
appears. Call the function concord, and accept the
input file name as an argument. Write the output to a file
called concord.txt. If a word is on more
than one line, the concordance will show you all of the
lines containing that word, and if a word appears multiple times in
a line, the line number should appear only once for that
word. Hint: Use parallel lists,
similar to what we did in the first part of the mode problem, to
solve this problem.
Input file contains:
I went to the restaurant
yesterday. Hello, I said, to the man who
greeted me at the door.
Where is your restroom? On my way to the
restroom, I bumped into the
waiter boy. Excuse me, sir, I said.
When I returned to the table,
the meal was served. These are the
best clams I have ever eaten,
I said. My compliments to the chef.
Unfortunately, I was arrested
by the officer for not paying my bill.
Produces in a file:
i [1, 3, 4, 5, 6]
went [1]
to [1, 2, 4, 5]
the [1, 2, 3, 4, 5, 6]
restaurant
[1]
yesterday
[1]
hello [1]
said [1, 3, 5]
man [1]
who [1]
greeted
[2]
me [2, 3]
at [2]
door [2]
where [2]
is [2]
your [2]
restroom [2,
3]
on [2]
my [2, 5, 6]
way [2]
bumped [3]
into [3]
waiter [3]
boy [3]
excuse [3]
sir [3]
when [4]
returned
[4]
table [4]
meal [4]
was [4, 6]
served [4]
these [4]
are [4]
best [5]
clams [5]
have [5]
ever [5]
eaten [5]
compliments [5]
chef [5]
unfortunately [6]
arrested
[6]
by [6]
officer
[6]
for [6]
not [6]
paying [6]
bill [6]
L10-8) (15 points) Modify a copy of 10-7 to
produce the same output, but with the words appearing in sorted
order.
please answer in python coding L10-5) (10 points) Write a program that reads in the contents of the file psalm112.txt a
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
please answer in python coding L10-5) (10 points) Write a program that reads in the contents of the file psalm112.txt a
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!