Question

PYTHON 3.6.1 write a script named copyfile.py. this script should prompt the user for the names...

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.

1 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code :


# to prompt the user to enter the file1 which is input file
infile=input("enter the input filename with extension ");

# to prompt the user to enter the file2 which is output file
outfile=input("enter the output filename with extension ");

#opening the file1 in reading mode
f1=open(infile,"r");

#opening the file2 in output mode
f2=open(outfile,"w+");

#reading the content of file1 to content variable
content=f1.read();

#writing to the value of content variable to file2
f2.write(content);

#closing the file1 and file2
f1.close();
f2.close();

Output :

Go to the path of the output file and open it with corresponding editor .Then you get the output .

File Edit Shell Debug Options Window Help Python 3.5.0 (v3.5.0:374150114567, Sep 13 2015, 02:27:37) [MSC V.1900 64 bit (AMD61

File Path :

View e) ▼ ↑-This pC 、 Desktop . python Search py ρ Name Date modified 29-04-2017 21:55 Tet Document 29-04-2017 22:01 Text Doc

Output file Content :

python This PC Desktop python Search py.. o ameen Notepad babu - Notepad File Edit Format View Help hi thi is ameen babu File

Add a comment
Know the answer?
Add Answer to:
PYTHON 3.6.1 write a script named copyfile.py. this script should prompt the user for the names...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT