****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.

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter9: Working With Text Functions And Creating Custom Formats
Section: Chapter Questions
Problem 1.7CP
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
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage