Please use python 3!!!!
# Write a function "get_file" to ask the user for a file
name.
# Return an open file handle to the users file in "read"
mode.
# Use exception handling to deal with the case that the user's
file
# does not exist, printing an error saying "File does not exist,
try again"
# and trying again
f = get_file()
f.close()
#!/usr/bin/python
def get_file():
#Reads the name of the file.
fileName = raw_input('Enter the name of the file to read: ')
try:
#Tries to read the file in read mode, and returns the handle.
fileHandle = open(fileName, 'r')
return fileHandle
except:
#Prints an error message, and retries, if fails to open the file.
print'File does not exist, try again.'
get_file()
f = get_file()
print f.read()
f.close()
Please use python 3!!!! # Write a function "get_file" to ask the user for a file...
Starting out with python 4th edition Write program that lets the user enter in a file name (numbers.txt) to read, keeps a running total of how many numbers are in the file, calculates and prints the average of all the numbers in the file. This must use a while loop that ends when end of file is reached. This program should include FileNotFoundError and ValueError exception handling. Sample output: Enter file name: numbers.txt There were 20 numbers in the file....
Write a program to read a text file, place each line it reads into an array. Then print the array’s contents one line at a time. Then add to the end of the text file “Success”. Use error exception handling and if the text file does not exist print "Error file not found." Always print "It worked." as part of the try clause. Upload a zip folder file of the .py and text file. roses are roses are red, violets...
Ask the user for the name of a file. Read a list of numbers of unknown length from the file. Find and print the MEDIAN and the MODE(S) of the set of numbers. Do not use python statistics functions to find the medium or mode To find the MODE(S) Create a dictionary using the numbers as the keys, and the values are how often that number appears in the list. For instance, with this list [1,1,5], the dictionary would be...
IN PYTHON Ask the user for a file name Open the requested file Split the contents of the file into words Iterate over each word Translate the word to Pig Latin Output the translated word to the screen How to Speak Pig Latin https://www.wikihow.com/Speak-Pig-Latin
Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...
(IN PYTHON) Download file homeruns.txt from Canvas. Your program must ask the user for the file name the read that file. Your program must catch an exception if the file isn’t found. It is a comma-delimited file with 2 fields on each line, a year and a number of home runs. Your program should have functions to determine the year with the most home runs, the year with the fewest number of home runs, and the average home runs for...
write a python program that prompts the user for a name of a text file, opens that file for reading , and tracks the unique words in a file and counts how many times they occur in the file. Your program should output the unique words and how often they occur in alphabetical order. Negative testing for a file that does not exist and an empty file should be implemented.
In python Count the frequency of each word in a text file. Let the user choose a filename to read. 1. The program will count the frequency with which each word appears in the text. 2. Words which are the spelled the same but differ by case will be combined. 3. Punctuation should be removed 4. If the file does not exist, use a ‘try-execption’ block to handle the error 5. Output will list the words alphabetically, with the word...
In python your goal is to ask the user for Nouns, Verbs, Adjectives… and fit them in the text where they appear. Each word should be unique. e.g. ask the user for a Noun and replace the first appearance of [Noun] in the text below by the user input. Technical requirements: Save the following text to a file. Open the file and replace all the words in between [] by user inputs using .format(). (You can manually modify...