Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called longestWord() that takes a filename (string) as an argument and returns the longest word in that file. Punctuation characters should not

Write a function called longestWord() that takes a filename (string) as an argument and returns the longest word in that file. Punctuation characters should not count towards the length of a word.

Write a function called writeLines() that takes a filename (string) and a list of strings as arguments and prints the given list to the given file. The function should replace the file if it already exists, and should create a new file if it does not already exist.

Write a function called reverseFile() that takes a filename (string) and creates a new file called reverse_filename, in which each line of text in the input file is printed in reverse. That is, the first line in the output file should be the last line of the input file, the second line of output should be the second last line of input. Each individual line should read the same (left-to-right) as it did in the input file.

Bonus: Write a function called followsWord() that takes a filename (string) and key-word (string) as arguments and returns a list of all unique words that follow the given keyword in the file. E.g. If the textfile contained "She sells sea shells by the sea shore", followsWord(textfile, "sea") would return ['shells','shore']. Both the keyword and the text of the file should be considered case insensitive. Note: your code should not crash in the case that the keyword is the last word in the fil

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

When, if ever, is a leader justified in using coercive power?

Answered: 1 week ago

Question

Measuring the Size of the Economy: Gross Domestic Product

Answered: 1 week ago