Question

In: Computer Science

Python Code Assignment 1. Place the two provided plaintext files (file_1.txt, file_2.txt) on your desktop. 2....

Python Code

Assignment

1. Place the two provided plaintext files (file_1.txt, file_2.txt) on your desktop.

2. Write a Python program named fun_with_files.py. Save this file to your desktop as well.

3. Have your program write the Current Working Directory to the screen.

4. Have your program open file_1.txt and file_2.txt, read their contents and write their contents into a third file that you will name final.txt .

Note: Ponder the open‐read/write‐close file operation sequence carefully.

5. Ensure your final.txt contains the complete text of file_1.txt followed by the complete text of   file_2.txt.  

Solutions

Expert Solution

To perform this we will open "final.txt" first then followed by "file1.txt"

perform read on file1 and fetch the content from file 1 and write it in final.txt

repeat same with file2

// code in python

f = open("final.txt", "w")
f1 = open("file1.txt", "r")
content1 = f1.read()
f.write(content1)
f1.close()
f2 = open("file2.txt", "r")
content2 = f2.read()
f.write(content2)
f2.close()
f.close()
f = open("final.txt", "r")
content = f.read()
print(content)
f.close()

// output

I am a software Developer.
Hi , I am anoop.I am a software Developer.

Process finished with exit code 0

//output

// File 1 content

//File2 Content

// Final.txt before running the program

//final.txt after running the program


Related Solutions

Assignment Requirements Write a python application that consists of two .py files. One file is a...
Assignment Requirements Write a python application that consists of two .py files. One file is a module that contains functions used by the main program. NOTE: Please name your module file: asgn4_module.py The first function that is defined in the module is named is_field_blank and it receives a string and checks to see whether or not it is blank. If so, it returns True, if not it return false. The second function that is defined in the module is named...
1. Copy the files from Assignment 1 to Assignment 2. Relabel as necessary 2. Create 3...
1. Copy the files from Assignment 1 to Assignment 2. Relabel as necessary 2. Create 3 instances of the PetFoodCompany class - dogFoodMaker, catFoodMaker, fishFoodMaker. 3. Internally set the division name for each instance. (I.E. "Alpo" for dogFoorMaker, "Purina" for CatFoodMaker, "GloFish" for fishFoodMater) 4. Prompt me to enter the Company Name and Quarter only once. 5. For each of the above instances, prompt me for total sales and total expenses. A loop is not expected. 6. For each instance...
For this assignment you are expected to submit the following two files: 1. ????ℎ??????ℎ??????. ℎ 2....
For this assignment you are expected to submit the following two files: 1. ????ℎ??????ℎ??????. ℎ 2. ????ℎ??????ℎ??????. ??? You are being asked to write a class for simple weather data storage. Each instance of the class will hold data for exactly one month (30 days). Each day’s weather will be classified as either rainy (‘R’), cloudy (‘C’), or sunny (‘S’). To achieve this, your class will contain a character array of length 30. The class will provide three functions to...
1. Copy the files from Assignment 1 to Assignment 3. 2. Modify the PetFoodCompany header to...
1. Copy the files from Assignment 1 to Assignment 3. 2. Modify the PetFoodCompany header to mention a friend function called "computeBonusBudget". This method should compute the bonus budget as netIncome() * BonusBudgetRate and this method should exist in the driver program - not the Class defintion. 3. Modify the output of the program to display the results of the computeBonusBudget. Enter Total Sales: 1000 Enter Total Expenses: 600 Net Income = 400 Bonus Budget = 8 Here is the...
I need the code in python where I can encrypt and decrypt any plaintext. For example,...
I need the code in python where I can encrypt and decrypt any plaintext. For example, the plaintext "hello" from each of these Block Cipher modes of Operation. Electronic Code Block Mode (ECB) Cipher block Mode (CBC) Cipher Feedback Mode (CFB) Output feedback Mode (OFB) Counter Mode (CTR) Here is an example, Affine cipher expressed in C. Encryption: char cipher(unsigned char block, char key) { return (key+11*block) } Decryption: char invcipher(unsigned char block, char key) { return (163*(block-key+256)) }
In this assignment you will start with Python code that builds a 2 host network connected...
In this assignment you will start with Python code that builds a 2 host network connected by a legacy router. You will modify it such that the two hosts can send packets to each other. It requires that you understand subnet addressing and the function of a router. The network built using Miniedit on a Mininet virtual machine: python mininet/examples/miniedit.py. We need to also make 6 static routes to make the program work. This is the work that I have...
In Python This assignment involves the use of text files, lists, and exception handling and is...
In Python This assignment involves the use of text files, lists, and exception handling and is a continuation of the baby file assignment. You should now have two files … one called boynames2014.txt and one called girlnames2014.txt - each containing the top 100 names for each gender from 2014. Write a program which allows the user to search your files for a boy or girl name and display where that name ranked in 2014. For example … >>>   Enter gender...
2. Combine multiple files Use Python programming to combine two text files: customer-status.txt and sales.txt Data...
2. Combine multiple files Use Python programming to combine two text files: customer-status.txt and sales.txt Data columns in customer-status.txt (separated by comma): Account Number, Name, Status 527099,Sanford and Sons,bronze Data columns in sales.txt (separated by comma): Account Number, Name, SKU, Quantity, Unit Price, Ext Price, Date 163416,Purdy-Kunde,S1-30248,19,65.03,1235.57,2014-03-01 16:07:40 527099,Sanford and Sons,S2-82423,3,76.21,228.63,2014-03-01 17:18:01 After you combine, you will see the following: 527099,Sanford and Sons,S2-82423,3,76.21,228.63,2014-03-01 17:18:01,bronze
In python and comments your code : Exercise 1 1.Write a function waiting for two matrices...
In python and comments your code : Exercise 1 1.Write a function waiting for two matrices and returning their addition, −1 if it is not not possible. 2. Write a function associated with a matrix and a scalar and returning the produced matrix. 3. Write a function accompanying an n × m matrix and a vector n and returning the vector produced by each other, −1 if this is not possible. 4. Write a function accompanying two n × m...
The files provided in the code editor to the right contain syntax and/or logic errors. In...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. DebugBox.java public class DebugBox { private int width; private int length; private int height; public DebugBox() { length = 1; width = 1; height = 1; } public DebugBox(int width, int length, height) { width = width; length = length; height =...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT