Many word processing programs allow the user to view properties of the text contained therein. For this problem, your task is to write a Python function that reads a text file and computes the total number of words and characters in the file.
The function has been started for you in the file wordcount.py. Modify this code as indicated and include the file in your homework submission.
Print (do not return any outputs) the statistics so that is looks identical to the sample below:
Processing file: sample.txt
Characters: 445
Words: 69
NOTE: For reference, the required modifications can be done in as little as 8-10 lines of code.
#reading file name from user
name=input("Enter file name : ")
#opening file
f1= open(name, "r")
wordCount=0
charCount=0;
for x in f1:
charCount=charCount+len(x)
wordCount=wordCount+len(x.split(" "))
print("Processing file: ",name)
print("Characters : ",charCount)
print("Words :", wordCount)

Many word processing programs allow the user to view properties of the text contained therein. For...
FIRST: Write code that prompts the user for the name of a text file, opens that file if it exists and reads the file one line at a time printing each line to the screen. You must implement the file read in a try/catch block rather than throwing the exception on the main method. NEXT: Modify your code so that the program takes the name of two files from the command line, opens the first file if it exists for...
Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that work with text files is the problem of locating a specific substring within the file. I am sure we’ve all done this many times when working with Word, Notepad, or other editors. Since we don’t have a GUI or other means of displaying the contents of a file all at once, let’s modify the problem slightly. Rather than locating a specific substring within a...
Help needed with Python 3: Dictionaries and Sets.
The problem is one that asks the user to create a completed
program that prompts the user for the name of a data file, and
reads the contents of that data file, then creates variables in a
form suitable for computing the answer to some questions.
The format should be in the same manner as the attached .py
file. All subsequent assignment details (.py and .csv files) can be
found at this...
C++
please
Project: Working with Text Write an object-oriented program the performs the following tasks: . Reads a text file provided along with this data and maintains it an object. Determines the number of characters and keeps in the object. Determines the number of words and retains the result in the object. Determines the number of paragraphs and keeps the result in the object. A possible class definition: class Textutil { string text = ** int words = @; int...
Hi, need this question ansered in c++, has multiple levels will
post again if you can complete every level so keep an eye out for
that.
here is a sketch of the program from the screenshot
int main (int argc, char** argv) { enum { total, unique } mode =
total; for (int c; (c = getopt(argc, argv, "tu")) != -1;) {
switch(c) { case 't': mode = total; break; case 'u': mode = unique;
break; } } argc -=...
SCREENSHOTS OF CODE ONLY!! PLEASE DON'T POST TEXT!! C++ CODE! PLEASE DON'T REPOST OLD POSTS! Objective To gain experience with the operations involving binary search trees. This data structure as linked list uses dynamic memory allocation to grow as the size of the data set grows. Unlike linked lists, a binary search tree is very fast to insert, delete and search. Project Description When an author produce an index for his or her book, the first step in this process...
In this assignment you’ll implement a data structure called a trie, which is used to answer queries regarding the characteristics of a text file (e.g., frequency of a given word). This write-up introduces the concept of a trie, specifies the API you’re expected to implement, and outlines submission instructions as well as the grading rubric. Please carefully read the entire write-up before you begin coding your submission. Tries A trie is an example of a tree data structure that compactly...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...
In the original flashcard problem, a user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting. A sample session might run as follows: Enter s to show a flashcard and q to quit: s Define: word1 Press return to see the definition definition1 Enter s to show a flashcard...