Write Python code to perform the following:
(i) Copy content of file first.txt to second.txt
(ii) Reading a file
(iii) Writing into a file
(iv) Appending into a file
(i) Copy content of file first.txt to second.txt in Python:
```python
with open('first.txt', 'r') as file1:
content = file1.read()
with open('second.txt', 'w') as file2:
file2.write(content)
```
(ii) Reading a file in Python:
```python
with open('filename.txt', 'r') as file:
data = file.read()
print(data)
```
(iii) Writing into a file in Python:
```python
with open('filename.txt', 'w') as file:
file.write("This is the new content.")
```
(iv) Appending into a file in Python:
```python
with open('filename.txt', 'a') as file:
file.write("\nThis line is appended.")
```
---
In ______ ___ _________ __________ ______ ____ ________.
_________ _________ _______ ________ _________ ______ _______ _________ _________.
_________ ___ _____ _______ _________ ___ _________.
_________ ________ ________ ____ _______ _________ ____ ____ __________.
________ ___ _________ ______ ____ ____ ________ _______ _____ ______ ____ _________.
________ ______ ________ ______ ________ ________ ____ ________ ________ _______ ________ _______.
___ ______ ___ _______ ___ _____ ___ _____ ________ _____ ____.
________ ____ __________ _____ ________ __________ ________ __________ ______ _________ _______ _________.
_____ _________ ________ _____ __________ __________ ___ _______ _____ ________.
________ _________ ________ _____ ____ _____ _________ __________ ______ ____ _________ ____.
_______ ______ _____ ___ ________ ________ ___ __________ __________ _______.
__________ __________ _____ _________ __________ ____ _____ _______ ____ ____ __________ ____.
________ ____ _____ ___ _______ _________.
_______ _________ ____ __________ _____ _____ _____ _______ ____ ________ ________ _______.
______ _________ ___ ______ ___ ____.
__________ _________ ________ ____ ______ ___ ___ ______.
_____ _______ _______ _________ ____ ____ __________ _____ ____ ___.
____ ___ ____ __________ _______.
_______ ____ ____ __________ ____ _____.
______ ____ ____ _________ __________.
____ ___ _______ _____ _________ ________.
________ ____ ___ ________ ____ _______ _________.
_____ _____ ______ ___ ____ ____ _______ ______ ____ _________ ____.
_________ ______ ________ __________ ______ _____ __________ ____ ________.
__________ ______ ______ _______ ____ _________ _________.
_____ __________ __________ ________ ____ ___ __________ _____ _________ ______.
_________ ____ _____ _________ _____ _____ _________ _________ _________ ____ ___.
__________ ___ ________ _____ ____ ____ ___ ___ ________.
__________ ___ ______ __________ _____ _____ ____ _________.
_______ _________ ______ ________ _____ _____ _____ ______ ________ ______ _________ _________.
_________ __________ ____ ___ _________ ______ ______ ______.
___ _________ _______ _________ ___ _______ __________ ______ ______ __________.
_________ _________ ____ _______ __________ _________ ______ __________ ________ __________ ____ ___.
_________ __________ ___ _____ _________ ______ ______ _____ _______ ________ ______.
______ ________ __________ ______ ________ ___ _________.
__________ _____ _______ _______ _______ ______.
_______.
Get Full Answer on WhatsApp