Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started