Please write a python code with 7 different functions in this template def main(): """Driver function: calls other functions to perform all tasks.""" lines = get_user_input() num_words = get_num_words(lines) num_sentences = get_num_sentences(lines) avg_words = get_avg_words(num_words, num_sentences) most_freq_word = get_most_used_word(lines) print_stat

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please write a python code with 7 different functions in this template

def main():
"""Driver function: calls other functions to perform all tasks."""
lines = get_user_input()
num_words = get_num_words(lines)
num_sentences = get_num_sentences(lines)
avg_words = get_avg_words(num_words, num_sentences)
most_freq_word = get_most_used_word(lines)
print_stats(num_words, num_sentences, avg_words, most_freq_word)
if __name__ == '__main__':
main()

 

o get_user_input() → list : Prompts the user for some text input, which can
include newlines (examples in week 5 lecture notes e). If interactive methods
do not work for you because the OS is using the usual key shortcuts for
something else, please see the screencasts explaining how to use a file
instead (while still accepting interactive input on systems that support it):
Coding Rooms screencast or PyCharm screencast.
o get_num_words(text_lines: list) → int : Returns the number of words; you
can assume words do not span multiple lines and are separated by
whitespace.
o get_num_sentences(text_lines: list) -> float : Returns the number of
sentences. You can assume that a sentence ends with one of the following
punctuation chars: ., ? or 9. You may not assume that a sentence is on a
single line.
o get_avg_words(num_words: int, num_sentences: int) -> float : Returns the
average sentence length rounded to one digit after the decimal point (e.g.,
4.3, but not 4.31).
o get_most_used_word(text_lines: list) -> str : Returns the most frequently
used word (case-insensitive). For ties, the word occurring first is chosen.
o print_stats(num_words: int, num_sentences: int, sent_avg_words: float,
most_freq_word: str): Print all results (number of words, number of
sentences, average sentence length) in a formatted table that is exactly 40
characters wide, see examples.
o The main() function should call other functions to perform all the required
work - no actual text processing, computation, formatting, or printing should
be done in main. This function is already provided for you in the template.
Transcribed Image Text:o get_user_input() → list : Prompts the user for some text input, which can include newlines (examples in week 5 lecture notes e). If interactive methods do not work for you because the OS is using the usual key shortcuts for something else, please see the screencasts explaining how to use a file instead (while still accepting interactive input on systems that support it): Coding Rooms screencast or PyCharm screencast. o get_num_words(text_lines: list) → int : Returns the number of words; you can assume words do not span multiple lines and are separated by whitespace. o get_num_sentences(text_lines: list) -> float : Returns the number of sentences. You can assume that a sentence ends with one of the following punctuation chars: ., ? or 9. You may not assume that a sentence is on a single line. o get_avg_words(num_words: int, num_sentences: int) -> float : Returns the average sentence length rounded to one digit after the decimal point (e.g., 4.3, but not 4.31). o get_most_used_word(text_lines: list) -> str : Returns the most frequently used word (case-insensitive). For ties, the word occurring first is chosen. o print_stats(num_words: int, num_sentences: int, sent_avg_words: float, most_freq_word: str): Print all results (number of words, number of sentences, average sentence length) in a formatted table that is exactly 40 characters wide, see examples. o The main() function should call other functions to perform all the required work - no actual text processing, computation, formatting, or printing should be done in main. This function is already provided for you in the template.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY