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 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...
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...
the language is python Instructions Forum Tutoring Problem program. Write a function concatenate_files(filename1, filename2, new filename) that concatenates the text from two source files such that the text from the file named by argument filename 2 follows the text from filename1. The concatenated text is written to a new file with the name given by new_filename. Your function O must not return anything. We have provided sample input files named part1.txt and part2.txt containing a portion of the text from...
(c programming): write a program that contains a function named getName, that does not get any parameter and returns a character array of a random name from a constant list of 30 names, in a global array. the function returns that random name. each name in the list is a character string that consists of not more than 20 characters(not including finishing 0). the name consists of only characters from the american alphabet (a-zA-Z) and does not contain any "white"...