****IN PYTHON! Write a function named file_stats that takes one string parameter (in_file) that is the name of an existing text file. The function file_stats should calculate three statistics about in_file: the number of lines it contains, the number of words and the number of characters, and print the three statistics on separate lines. For example, the following would be the correct input and output: >>> file_stats('created_equal.txt') lines 2 words 13 characters 72 Note: The number of characters may vary slightly between operating systems. Similarly, the number of lines may vary by 1 line, depending on the method used to calculate it.   I attached a picture of my code so far and a picture of what the text file reads.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

****IN PYTHON!

Write a function named file_stats that takes one string parameter (in_file) that is the name of an existing
text file. The function file_stats should calculate three statistics about in_file: the number of lines it
contains, the number of words and the number of characters, and print the three statistics on separate
lines. For example, the following would be the correct input and output:
>>> file_stats('created_equal.txt')
lines 2
words 13
characters 72
Note: The number of characters may vary slightly between operating systems. Similarly, the number of lines
may vary by 1 line, depending on the method used to calculate it.

 

I attached a picture of my code so far and a picture of what the text file reads.

#Exercise 2
text_in=open('/Users/kristynpatracuolla/Documents/dummy_3.txt.rtf')
file_stats('/Users/kristynpatracuolla/Documents/dummy_3.txt.rtf')
Transcribed Image Text:#Exercise 2 text_in=open('/Users/kristynpatracuolla/Documents/dummy_3.txt.rtf') file_stats('/Users/kristynpatracuolla/Documents/dummy_3.txt.rtf')
Helvetica
î Regular
↑
dummy_3.txt.rtf - Edited
12
a
4
B I U
1.0
2
3
5
0
6
7
The average temperature of Newark New Jersey on a Summer day is seventy degrees. The weather is very
nice. I love the weather. When it is warm out I like to wear shorts and sneakers. The sun shines nicely on
campus.
Transcribed Image Text:Helvetica î Regular ↑ dummy_3.txt.rtf - Edited 12 a 4 B I U 1.0 2 3 5 0 6 7 The average temperature of Newark New Jersey on a Summer day is seventy degrees. The weather is very nice. I love the weather. When it is warm out I like to wear shorts and sneakers. The sun shines nicely on campus.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education