1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Viktor [21]
3 years ago
11

Create a function copy() that reads one file line by line and copies each line to another file. You should use try-except statem

ents and use either open and close file statements or a with file statement.>>>def copy(filename1, filename2) :
Computers and Technology
1 answer:
Anna71 [15]3 years ago
7 0

Answer:

See attachment for answer

Explanation:

I could not add the answer; So, I made use of an attachment

The program is written on 9 lines and the line by line explanation is as follows:

Line 1:

This defines the function

Line 2:

This begins a try except exception that returns an exception if an error is encountered

Line 3:

This open the source file using open and with statement

Line 4:

This open the destination file using open and with statement and also makes it writable

Line 5:

This iterates through the content of the source file; line by line

Line 6:

This writes the content to the destination file

Line 7 & 8:

This is returned if an error is encountered

Line 9:

This prints that the file has been successfully copied        

To call the function from main; use

copy(filename1, filename2)

Where filename1 and filename2 are names of source and destination files.

Take for instance:

filename1 = "test1.txt"

filename1 = "test2.txt"

copy(filename1, filename2)

<em>The above will copy from test1.txt to test2.txt</em>

Download txt
You might be interested in
What are common tasks Human Services workers perform? Check all that apply.
Ainat [17]

Answer: B, D, E, F

Explanation:

I got I right.

7 0
3 years ago
Read 2 more answers
Use the drop-down menu to complete the sentences about the benefits of flowcharts.
mojhsa [17]

Answer:

c,a,c using the drop down menus edge 2021

GOODLUCK

Explanation:

4 0
3 years ago
Basic python coding, What is the output of this program? Assume the user enters 2, 5, and 10.
r-ruslan [8.4K]

Answer:

17.0

Explanation:

after first loop numA = 0.0 + 2 = 2.0

after second loop numA = 2.0 + 5 = 7.0

after third loop numA = 7 + 10 = 17.0

8 0
3 years ago
Using productivity software ensures that the end product will look professional. Please select the best answer from the choices
borishaifa [10]

Answer:

False

Explanation:

5 0
3 years ago
Return true if the given non-negative number is a multiple of 3 or 5, but not both. Use the % "mod" operator.
Pani-rosa [81]

the following C++ function will return true if the given non - negative number is multiple of 5 or 3 else it will return false.

bool function( int x ){

// variable to check if it is multiple of both or not

int number =0;

if(3%x == 0){

number++;

}

if(5%x == 0){

number++;

}

// Now returning by deciding

if( number <=1)

return true;

else

return false

}

4 0
4 years ago
Other questions:
  • When you start to type =av, what feature displays a list of functions and defined names?
    11·1 answer
  • What is processor, memory RAM, cDRAM,DVD RAM,video card​
    9·1 answer
  • The Knowledge Consistency Checker (KCC) ensures the maximum number of hops between any two domain controllers does not exceed wh
    12·1 answer
  • Your program Assignment Write a program that reads a sentence as input and converts each word to "Pig Latin". In one version of
    15·1 answer
  • Which of the following can a cell contain?
    9·2 answers
  • How many fixes are available for Adobe Photoshop CS4 (64 Bit)?
    9·1 answer
  • Which of the following is NOT a reason to include comments in programs
    10·2 answers
  • Search the Web for three different employee hiring and termination policies. Review each and look carefully for inconsistencies.
    5·1 answer
  • JAVA CODE.
    6·1 answer
  • What is the difference between HTML and XML?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!