Write a PYTHON program that reads a file (prompt user for the
input file name) containing two columns of floating-point numbers
(Use split). Print the average of each column. Use the following
data forthe input file:
1 0.5
2 0.5
3 0.5
4 0.5
The output should be:
The averages are 2.50 and 0.5.
a) Your code with comments
b) A screenshot of the execution
Version 3.7.2
filename = input('Enter file name: ')
with open(filename, 'r') as f:
total1, total2, count = 0, 0, 0
for line in f:
words = line.strip().split()
total1 += float(words[0].strip())
total2 += float(words[1].strip())
count += 1
print("Averages are {} and {}".format(total1/count, total2/count))

Write a PYTHON program that reads a file (prompt user for the input file name) containing...
Write a Python program that reads from user the input file called data.txt that consists of a keyword followed by a sequence of numbers separated by commas. If the keyword is UP, the numbers are sorted in increasing order, if the key word is DOWN, the numbers are sorted in decreasing order. The sorted sequence of numbers are saved in sorted.txt
Python Error: Writing a program to complete the following: Prompt the user for the name of an input file. Open that file for input. (reading) Read the file using a "for line in a file" loop For each line, o print the line and compute and print the average word length for that line. Close the input file Sample output: MY CODE IS WRONG AND NEED HELP CORRECTING IT!!! ------------------------------------------------------------------------------------------------------------------------ DESIRED OUTPUT: Enter input file name: Seasons.txt Thirty days hath September...
python code:
Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the file consists of the postcode followed by a tab followed by a comma-separated list of locations that have that postcode. For example, the file Small.txt contains: 3015 Newport,South Kingsville,Spotswood 3016 Williamstown 3018 Altona,Seaholme 3019 3021 Albanvale,Kealba,Kings Park,St Albans Braybrook, Robinson Your program should create a list of postcode/location pairs with each pair stored...
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
Write a PYTHON program that reads in three strings and sorts them lexicographically. Do NOT user the sort function. Enter string 1: Charlie Enter string 2: Able Enter string 3: Baker Able Baker Charlie Your code with comments A screenshot of the execution Test Cases: Able, Baker, Charlie Baker, Charlie, Able Charlie, Able, Baker Able, Charlie, Baker Baker, Able, Charlie Charlie, Baker, Able
C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...
Write a perl program Use a while loop to get user input until the user enters "quit" Use a regex to replace any occurrence of the word "python" with the word "perl" and print out the updated version Provide the perl program (.pl file) as well as a screenshot of the output (show at least one example with python being replaced)
(Count the occurrences of each keyword) Write a python program that reads in a Python source code file and counts the occurrence of each keyword in the file. Your program should prompt the user to enter the Python source code filename.
Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...
Python
3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018
3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018