hey please answer in python 3
This is the test for these questions. it has to be exactly the same as the Expected output.
notice my code is very close to getting it but im always off by 0.01 or 0.02.
Thank you for the help!
Below is the python3 code for mentione problem statement:
You can comment and uncomment below line in the code for implementing with or without apsotrophe.
word = remove_apos(word)
def remove_apos(word_string):
# remove apostrophe in the word
word_string = word_string.replace("'",
"")
return word_string
if __name__ == '__main__':
# user input
print("Enter name of file : ")
file_name = input()
print("File to be processed is : ",
file_name)
# open file
open_file = open(file_name)
file_contents = open_file.read()
# ignore following symbols if exits in file
because these are not considerable for word.
# ignore_char =
'''!()-;:'",.?_~1234567890'''
ignore_char =
'!()-;:",.?_~1234567890'
words_counter = 0 # Count of words
total_counter = 0 # Sum of lengths of all
the words
for charracter in ignore_char:
file_contents =
file_contents.replace(charracter, '')
# spliting the file contents in the
words
for word in file_contents.split():
#
comment or uncomment the below line as per with or without
apostrophe implementation
word =
remove_apos(word)
print(word)
words_counter =
words_counter + 1
total_counter =
total_counter + len(word)
avg_word_len = total_counter /
words_counter
print("The number of words is : ",
words_counter)
print("The average length of a word is : ",
"{:.5f}".format(avg_word_len))
Note: Kindly like and upvote the answer, if it helped you. In case of any query, just comment. I would be very happy to resolve all your queries.
Please find the screenshots of code and output.
hey please answer in python 3 This is the test for these questions. it has to...
Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...
Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...
Problem 3 Write a function named repeat_words that takes two string parameters: 1. in_file: the name of an input file that exists before repeat_words is called 2. out_file: the name of an output file that repeat_words creates Assume that the input file is in the current working directory and write the output file to that directory. For each line of the input file, the function repeat_words should write to the output file all of the words that appear more than...
Python 3.6 Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file exists when wordLengths is called; wordLengths must create the file outFile. The input file contains only letters and white space For each line of the input file, wordLengths should identify the length of the longest word...
Write a C program to run on ocelot to read a text file and print it to the display. It should optionally find the count of the number of words in the file, and/or find the number of occurrences of a substring, and/or take all the words in the string and sort them lexicographically (ASCII order). You must use getopt to parse the command line. There is no user input while this program is running. Usage: mywords [-cs] [-f substring]...
In this lab you will write a spell check program. The program has two input files: one is the dictionary (a list of valid words) and the other is the document to be spellchecked. The program will read in the words for the dictionary, then will read the document and check whether each word is found in the dictionary. If not, the user will be prompted to leave the word as is or type in a replacement word and add...
Capitalization JAVA In this program, you will read a file line-by-line. For each line of data (a string), you will process the words (or tokens) of that line one at a time. Your program will capitalize each word and print them to the screen separated by a single space. You will then print a single linefeed (i.e., newline character) after processing each line – thus your program will maintain the same line breaks as the input file. Your program should...
Need some help on this Python Problem called "unique words" the text.txt file can be any .txt file with words in it. Write a program that opens a specified text file and then displays the number of unique words in the text file after stripping all the white spaces, comma, and the punctuation marks and list of all the unique words found in the file. The list should be sorted in alphabetical order. The program should handle the ‘file not...
Homework IX-a Write a program that opens a text file, whose name you enter at the keyboard You will be using the file text.txt to test your program. Print out all of the individual, unique words contained in the file, in alphabetical order Print out the number of unique words appearing in text.txt. Call your program: YourName-HwrklXa.py Make sure that your name appears as a comment at the beginning of the program as well as on the output display showing...
Python program This assignment requires you to write a single large program. I have broken it into two parts below as a suggestion for how to approach writing the code. Please turn in one program file. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of...