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
  • on a mac!!!!!! Write a script named copyfile.py. This script should prompt the user for the...

    on a mac!!!!!! 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.

  • For Python | Instructions Write a script named difpy. This script should prompt the user for...

    For Python | Instructions Write a script named difpy. This script should prompt the user for the names of two text files and compare the contents of the two files to see if they are the same. 1. If they are the script should simply output "Yes". 2. If they are not the script should output "No", followed by the first lines of each file that differ from each other The input loop should read and compare lines from each...

  • Programming Exercise 4.9 Write a script named numberlines.py. This script creates a program listing from a...

    Programming Exercise 4.9 Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the user for the names of two files. The input filename could be the name of the script itself, but be careful to use a different output filename! The script copies the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns,...

  • computer programming python

    Write a script named dif.py. This script should prompt the user for the names of two text files and compare the contents of the two files to see if they are the same.If they are, the script should simply output "Yes". If they are not, the script should output "No", followed by the first lines of each file that differ from eachother. The input loop should read and compare lines from each file. The loop should break as soon as...

  • Write a python program that prompts the user for the names of two text files and...

    Write a python program that prompts the user for the names of two text files and compare the contents of the two files to see if they are the same. If they are, the scripts should simply output “Yes”. If they are not, the program should output “No”, followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file. The loop should break as soon as a...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • Write a Python script in that will prompt the user to enter a string. After the...

    Write a Python script in that will prompt the user to enter a string. After the user enters their string print its length and the ordinal value of the first, third, and seventh character. Assume the input will be of sufficient length. Use "nice" input and output

  • **Python script** to input from user an URL, fetch the page contents using requests, and save...

    **Python script** to input from user an URL, fetch the page contents using requests, and save the respective page contents to an appropriately named text file. Wrap this request code in its own function: eg create a function getPageRequests(url).

  • 1. Write a function to keep asking the user for names in the form of strings,...

    1. Write a function to keep asking the user for names in the form of strings, sort alphabetically and store these names into a text file named names.txt 2. Write a function that accepts a string as the argument, removes all alphabetical letters from the string, and returns it 3. Write a function that accepts a file name in the form of a string as the argument. Assume the text file contains single-digit numbers and letters. Read the entire contents...

  • Make two files, cats.txt and mynewcats.txt. Store at least three names of cats in cats.txt file....

    Make two files, cats.txt and mynewcats.txt. Store at least three names of cats in cats.txt file. Write a python program that tries to read the first file and print the contents of the file to the screen. Prompt the user to enter three cats names and save them into mynewcats.txt file.

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