Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.6 Question 12 (2e points) Write a function named filestats. The function filestats takes two string parameters: inFile, the name of an input file

Python 3.6

image text in transcribed

Question 12 (2e points) Write a function named filestats. The function filestats takes two string parameters: inFile, the name of an input file and outFile, the name of an output file The function filestats should read and analyze the contents of the input file and write the statistics it compiles to the output file. The statistics you should compute about the input file are: the number of characters; the number of words; * the number of lines ? *the number of digits; *the number of punctuation marks Each statistic should be written to a separate line of the output file. (Hint: the string class contains constants named punctuation and digits.) For example, if the input file contains the following lines: Lord I'm one, Lord I 'm two, Lord I'm three, Lord I'm four, Lord I'm 500 miles from my home 50? miles, 500 miles, 500 miles, 500 miles Lord I'm five hundred miles from my home Then an output file with the following lines would be correct: characters 181 words 35 lines 4 digits 15 punctuation 15

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

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