Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Name your file: analyze.py and submit to CodePost. See full submission requirements at the end. Write a function called analyze_paragraphs that takes the name of

Name your file: analyze.py and submit to CodePost. See full submission requirements at the end.

Write a function called analyze_paragraphs that takes the name of a file as a parameter and that produces output that describes the paragraph structure of the file, returning the maximum number of lines in any given paragraph. Each paragraph in the input file will be terminated by the text

on a line by itself. For example, consider the following input file:

 This is an example of an input file with four different paragraphs. 

The second paragraph is the longest with three lines, so your function should return 3 when processing this file.

The third paragraph was empty. This one is just short.

The function should count the number of lines in each paragraph and print that information. For example, if the input above is stored in a file called input.txt and we make the following call:

 max = analyze_paragraphs("input.txt") 

It should produce the following output:

 2-line paragraph 3-line paragraph 0-line paragraph 1-line paragraph 

It would assign max the value 3 because the function returns the maximum number of lines in any given paragraph. You must exactly reproduce the format of this output. You may assume that the input file contains at least one paragraph, and that each paragraph is terminated by a line containing just

analyze_main.py

from analyze import * def main(): print("maximum number of paragraphs in test1.txt: ", analyze_paragraphs("test1.txt")) print("maximum number of paragraphs in test2.txt: ", analyze_paragraphs("test2.txt")) main()

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago

Question

2. How will you handle the situation?

Answered: 1 week ago