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

1 from analyze import * 2 3 def main(): print(\"maximum number of paragraphs in testi. txt: 4 ', analyze_paragraphs(\"test1.txt\")) 5 6 print(\"maximum number of paragraphs in test2.txt: \", analyze_paragraphs(\"test2.txt\")) N 00 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_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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Find the area of the shaded region. r?= sin 20

Answered: 1 week ago