43. Write a program that reads a file and writes a copy of the file to another file with line numbers inserted.
Q: ’POLISH’ PEASANT MULTIPLICATION Write a program using a language of your choice, that multiply two…
A: We have to create a program in Python that implements the "Polish Peasant Multiplication" method. To…
Q: Write a program in a script file that finds the smallest odd integer that is divisible by 11 and…
A: here in the given question ask for a program,
Q: #Problem #1 Searching for a Item in a File Write a program named SearchFile.py that reads in a list…
A: Algorithm for SearchFile.py1. Define the search_file Function:Open the specified file in read…
Q: Write, Compile and Execute a Java program that creates a file named Exercise.txt and writes 100…
A: import java.io.File; import java.io.IOException; import java.io.FileWriter; import…
Q: Write a program that asks the user for the name of a file. The program should display the contents…
A: Since no programming language is mentioned, the given program is in the Python language.
Q: 14: files.cpp) Write a program that reads a file encoded with the "rot13" cypher, decodes it, and…
A: Program description : The c++ program, files.cpp will read an input file , myfile.txt .Then file,…
Q: This week’s assignments deal with files and nested loops. Input: The program prompts for the name of…
A: “Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: The following lines of code should open a file for writing (output). The name of the by the user.…
A: open is the function used to open the file and here we specify the filename and mode of operation
Q: Q2: Write a complete C++ program that reads the contents of the text file "mydata.txt", word by…
A: #include <bits/stdc++.h> using namespace std; // driver code int main() { fstream file; int…
Q: 2) Write a program which takes two points from a file and prints the distance between them to…
A: Actually, program is a executable software that runs o a computer.
Q: Exercise 6 - File Writing Create a new class called Filewriting. In this class, implement a program…
A: 1. create Scanner from system.in to read strings from user. 2. create BufferedWriter to write…
Q: 15. When we are done using a file with a C program, what do we do with the file? O Close it Throw it…
A: The question is asking about the best practice to follow when we are done using a file in a C…
Q: PYTHON without def function Suppose an input file (called "scores.txt") contains a number on each…
A: # Read the filesco = open("scores.txt", "r") # Extract the file contentsco_l1 = str(sco.read()) #…
Q: 6.b. What are the different modes of opening a füle? Write a program to create a file "hello.txt'%…
A: A file is a container in computer storage devices used for storing data. It allows to create,…
Q: Q2: Write a complete C++ program that reads the contents of the text file "mydata.txt", character by…
A: Below is the required C++ program: - Approach: - In the given program two files are open one in read…
Q: Merge two files (1 point) Write a program that reads the content of two files “text1.txt” and…
A: Actually, file is a sequence of bytes where related data stored.
Q: Exercise 1: Write a Python program that reads from the user the name of two files (an input file and…
A: input_filename=input("Enter input file name: ") # taking input file nameoutput_filename=input("Enter…
Q: Write a program that opens a file taking the file name as user input and implement the following:…
A: The asked python program using Input/Output operations is given in the next step having comments for…
Q: Solve the exercise specified by your instructor and submit the python source file before the…
A: 1) Make a file names input.txt and put the below text Mary had a little lamb;Whose fleece was white…
Q: 5. Sum of Numbers Assume a file containing a series of integers is named numbers.txt and exists on…
A: I give the code in Python along with output and code screenshot
Q: 10. Write a program to count the number of vowels present in a text file.
A: This code given below defines a function count_vowels that takes a file name as a parameter and…
Q: a) What is the benefit of the statement temp = number ; for the program? What will happen if we…
A: The effect of this will be observed when we try to compare the 'reverse' and 'number' for equality.
Q: Problem P7.9 - Algorithm design, file input, file output, iteration Write a program that reads each…
A: We are going to use the reverse() method to generate a reversed iterator.The Python code is shown…
Q: Write a short notes on the following appending to a file deleting a file
A: a short notes on the following appending to a file deleting a file
Q: containing a list of photo file names. The program then reads the photo file names from the text…
A: Code: file = open("ParkPhotos.txt") for i in file: temp = i.strip().replace(…
Q: Question #1 The following program reads integer numbers from a file named numbers.txt. For each…
A: In the given program a data file is read and for every number in the file it is checked for a…
Q: please see attached files C++
A: Coded using C++.
Q: Assume that a file containing a series of names (as strings) is named names.txt and exists on the…
A: Program:-
Q: 2:56 D Write a program that finds the number of times a specific word appears in a text file. The…
A: Code: #include <iostream>#include <fstream>#include <algorithm>using namespace…
Q: Write a Python program that reads from the user the name of two files (an input file and an output…
A: code :-- # getting the input an output file name from user file_in = input('Enter input file name :…
Q: Write a program that gets integer input from user until the user gives a value bigger than 50 by…
A: import java.util.Scanner;public class Upto50 { public static void main(String[] args) {…
Q: Q1: Suppose that the file (rectangle.txt) shown in the figure was stored in the default path, this…
A: Use input stream to read data from rectangle.txt Use output stream to write data to areas.txt
Q: Count characters, words, and lines in a file Write a program that will count the number of…
A: Writing this code on Python Language version 3.9 CODE:- filename = input("Enter file name: "); #…
Step by step
Solved in 2 steps
- program - python Write a program using a for loop that creates a file and adds even numbers the integers 1 through 20 loop to the file. Name the file numbers. txt. Then perform the following on the file: Read all of the numbers stored in the file and calculate their total. Display all the numbers in the file and the calculated total Using a for loop add the following numbers to the file 21 through 30 Delete the following numbers from the file 24, 25, 26 (using a temp.txt file) Change the number 10 to 50 (using a temp.txt file) Hint: if you want to use ! Use module os that is part of Python to manipulate files.: import os. You can use functions that come with “os” module. Functions remove and rename can be used as explained below. rename(old_name,new_name):This function renames the old_name to new_name). remove(filename)method in Python is used to remove or delete a file.Which of the following statements are true? A) When you open a file for reading, if the file does not exist, an error occurs. B) When you open a file for writing, if the file does not exist, a new file is created. C) When you open a file for reading, if the file does not exist, the program will open an empty file. D) When you open a file for writing, if the file exists, the existing file is overwritten with the new file. E) When you open a file for writing, if the file does not exist, an error occurs. ======================================================================================= A, B, and D only A, and E B, and D only A and B onlyD) Create a program that will read a text file with the answers to 10 multiple-choice questions and compare them to the correct answers stored in a tuple. correct answers: 'A','B','C','D','D','C','B','A','A','C' After the answers have been read from the file, the program should display a message indicating whether the answer stored on the file was correct or not. If the answer was was incorrect, display the correct answer. The program should display the total number of correct and incorrect answers, followed by a message of "Good job!" if the file has 8 or more correct answers. PYTHON
- PYTHON: I need to get the avg statement out of the loop so that the output prints correctly. Any suggestions. Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam…Exercise 2 (30/40): Write a program that reads in a set of coin descriptions from a file. The input file has the format coinNamel value is coin Valuel coinName2 value is coinValue2 Add a method to your program that receives file content and writes back to another file statistics about the coins. Sample input file Riyal value is 25 Baisa value is 6.0 BHR value is baisa value is 5.30 Riyal value is 23.5 Sample output file Riyal = 24.25 Baisa =5.65 BHR = 9.5 In the solution 1. use the coin class provided on Moodle. 3. Handle any two exceptions to make sure the input file holds the correct transactions format (FileNotFoundException is not one of them) Information: 9.5 ● Illegalargumentexception: The IllegalArgumentException is an unchecked exception in Java that is thrown to indicate an illegal or unsuitable argument passed to a method. It is one of the most common exceptions that occur in Java. InputMismatchException: The InputMismatchException generally occurs when working with Java…Java Program ************This program must work in hypergrade and pass all the test cases.********** Chapter 9. PC #14. Word Separator (modified *** Read carefully ***) Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it line by line. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name. The file can contain one or more sentences. The program should accept as input each sentence in which all the words are run together, but the first character of each word is uppercase. Convert sentences to strings in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string StopAndSmellTheRoses.” would be converted to “Stop and smell the roses.” Sentences are separated by periods ('.'), exclamation marks ('!'), or…
- Need assistance in using disk files for C programming.Help C++Exercise 5: Write a Python program that reads each line of an input file original.txt and saves in a file called analysis.txt the line number, the number of words and characters found in that line without counting punctuations separating the words or found at the end of the line. For example, if the original.txt file is: In COMP2101, the students learn basic programming skills. Which includes: arithmetic and logical expressions, decisions, and loops. They will also learn how to read and write from keyboards and files. The file analysis.txt will contain Line1, 8 words and 48 characters Line2, 9 words and 61 characters Line 3, 13 words and 55 characters
- Part b Python1 Encryption (a). Write a program that will utilise AES for encrypting and decrypting the data from a file as follows. Your program should take 3 arguments from the command line as input. The first input should be either 0 or 1 referring to encryption or decryption, respectively. The second input is the key filename. The third input is the either the plaintext or encrypted filename. If the first argument is 0: your program will read an AES key from a file titled key.txt (passed as second argument) and then will read the plaintext from a file titled plain- text.txt (passed as third argument), encrypt the contents of plaintext.txt using the key and save the ciphertext in a file titled encrypted.txt. If the first argument is 1, your program should decrypt the contents of encrypted.txt. Sample Command-line Inputs: java 0 key.txt plaintext.txt java 1 key.txt encrypted.txtQ4. Write an algorithm of a program to read from a file. The user should be able to get the option to input the file name. He is supposed to read first 100 bytes from the file. After the reading is done, the file should be closed. If the file is not available, the program should be closed immediately. You should mention "System call" beside each instruction which are supposed to use a system call function. *