In: Computer Science
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.
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
