Programming Exercise 4.9
Write a script named numberlines.py. This script creates a program listing from a source program.
This script should:
Prompt the user for the names of two files.
The input filename could be the name of the script itself, but be careful to use a different output filename!
The script copies the lines of text from the input file to the output file, numbering each line as it goes.
The line numbers should be right-justified in 4 columns, so that the format of a line in the output file looks like this example:
1> This is the first line of text.
input_filename = input('Enter input file name: ') output_filename = input('Enter output file name: ') with open(input_filename, 'r') as f, open(output_filename, 'w') as w: number = 0 for line in f: number += 1 w.write('{:>4}> {}'.format(number, line))
Programming Exercise 4.9 Write a script named numberlines.py. This script creates a program listing from a...
For Python
| Instructions Write a script named difpy. This script should prompt the user for the names of two text files and compare the contents of the two files to see if they are the same. 1. If they are the script should simply output "Yes". 2. If they are not the script should output "No", followed by the first lines of each file that differ from each other The input loop should read and compare lines from each...
on a mac!!!!!!
Write a script named copyfile.py. This script should prompt the user for the names of two text files. The contents of the first file should be input and written to the second file.
PYTHON 3.6.1 write a script named copyfile.py. this script should prompt the user for the names of two text files. the contents of the first file should be input and written to the second file.
Write a script named dif.py. This script should prompt the user for the names of two text files and compare the contents of the two files to see if they are the same.If they are, the script should simply output "Yes". If they are not, the script should output "No", followed by the first lines of each file that differ from eachother. The input loop should read and compare lines from each file. The loop should break as soon as...
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 program in C that creates an array of 100 random numbers from 0-99. The program sums the random numbers and prints the sum. It then writes the numbers to a new file using open, close and write. Then looks in the current directory for files that match the pattern “numbers.XXXX”. For each file, open the file and read the file. You can assume that the file will contain 100 integers. Sum the integers. Print the filename and the sum...
Write c program. Do part 4 and 5
CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns 1-4 6-8 number of a student A grade out of 100 EYERCISE 12-4 Write a program that will read the identification numbers of students and their letter grades (A, B, C, D, or F) from the keyboard and store them in a text file...
Write a program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when I test this. Do not use a path name when opening these files. This means the files should be located in the top level folder of the project. Do not use a copy method that is supplied by Java. Your program must read the file line by line...
Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1. The input and variable value file are both text files that will be specified in...
Please write this in C.
Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. 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 opening any of the 3 For example, (user input shown in caps in first line) Enter first...