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
11111nata11111 [884]
3 years ago
6

The following code segment is supposed to read all of the lines from test.txt and save them in copy.txt. infile = open("test.txt

", "r") outfile = open("copy.txt", "w") line = infile.readline() ____________________ outfile.write(line) line = infile.readline() infile.close() outfile.close() Which line of code should be placed in the blank to achieve this goal?
Computers and Technology
1 answer:
alukav5142 [94]3 years ago
5 0

Answer:

The line of code that should be placed is

while line:

The entire code should be as follows:

  1. infile = open("test.txt", "r")
  2. outfile = open("copy.txt", "w")
  3. line = infile.readline()
  4. while line:
  5.    outfile.write(line)
  6.    line = infile.readline()
  7. infile.close()
  8. outfile.close()

Explanation:

The Python built-in function <em>readline() </em>will read one line of text from <em>test.txt</em> per time. Hence, the code in Line 3 will only read the first line of text from <em>test.txt</em>.

To enable our program to read all the lines and copy to <em>copy.txt</em>, we can create a <em>while </em>loop (Line 5) to repeatedly copy the current read line to <em>copy.txt </em>and proceed to read the next line of text from<em> test.txt </em>(Line 6 -7).

"while line" in Line 5 means while the current line is not empty which denotes a condition of True, the codes in Line 6-7 will just keep running to read and copy the text until it reaches the end of file.

You might be interested in
What were the advantages and disadvantages of agricultural technology to us.
Digiron [165]

Advantages of technology in agriculture include expediting crop production rate and crop quantity, which in turn reduces costs of production for farmers and food costs for consumers, and even makes crops more nutritious and livestock bigger and meatier.

The excessive use of chemicals by the help of machines reduces the fertility of the land.Lack of practical knowledge the farmers cant handle the machines properly.While the cost of maintenance is very high.Overuse of machines may lead to environmental damage.It is efficient but has many side effects and drawbacks.

5 0
3 years ago
Read 2 more answers
Explain the concepts o f polymorphism, Encapsulation, Inheritance in detail with suitable examples?
levacccp [35]

Answer:

Encapsulation:-It is the binding of the data and functions so that they works as one unit.

Inheritance:-When one class acquires the property of another class it is called inheritance.

Polymorphism :-It generally means more than one form

Explanation:

Encapsulation:- class is an example of encapsulation it can hold different data types and functions in a single container called class.

class Name{

public:

string first_name;

string last_name;

void Display()

{

cout<<first_name<<" "<<last_name<<endl;

}

};

Inheritance:-The property of a class acquiring the properties of another class is called inheritance.

Now we will inherit the above defined class.

class person: public Name

{

public:

char gender;

int age;

void Display()

{

cout<<first_name<<" "<<last_name<<gender<<age<<endl;

}

};

int main()

{

Name n;

person p;

n.Display();

p.Display();

}

Polymorphism- There are two types of polymorphism:-

1.Run time polymorphism=The values are decided at run time.

2.Compile time polymorphism=The values are decided at compile time.

Example:-In the above example we have function Display() in both the classes.This is an example of compile-time polymorphism. We are deciding at the time of compilation which display to use.

8 0
4 years ago
In your own words, describe what an acceptable use
astraxan [27]

The acceptable use policy is known to be a policy that is made up of  practices that all its users need to agree to in order to be able to make use of such network or other resource.

The items are:

  • Social media page .
  • Internet address, applications.
  • Accessing private or confidential information.

<h3>What is an acceptable use policy?</h3>

An acceptable use policy (AUP) is known to be document that is said to tell about the  constraints as well as the practices that a user need to agree to be able to  access a  given corporate network or the Internet.

Therefore, The acceptable use policy is known to be a policy that is made up of  practices that all its users need to agree to in order to be able to make use of such network or other resource.

Learn more about acceptable use policy from

brainly.com/question/2625500

#SPJ1

6 0
2 years ago
Which web design concept is most closely related to elements that symbolize the real world? A. node B. landmark c.metaphor IN D.
sergij07 [2.7K]

Answer:

landmark

Explanation:

6 0
3 years ago
_____ refers to software for creating, maintaining, and manipulating data. group of answer choices extranet rom internet 2 ram d
Sliva [168]

Database management system (DBMS) refers to software for creating, maintaining, and manipulating data.

In the field of software engineering, a database management system (DBMS) can be described as a software whose function is to properly manage a database. Any kind of data in a database can be created, changed, or retrieved through the database management system (DBMS).

It is through the database management system (DBMS) that data is created, gets secured and its integrity is maintained. Through the database management system (DBMS), a certain piece of data can be assessed by various people at the same time from different locations.

Some examples of database management systems are columnar DBMS, NoSQL DBMS, and in-memory DBMS.

To learn more about the database management system (DBMS), click here:

brainly.com/question/19089364

#SPJ4

5 0
2 years ago
Other questions:
  • Which of the following situations would not require knowledge of networking?
    6·1 answer
  • _______ computing refers to applications and services that run on a distributed network using virtualized resources.
    14·1 answer
  • A _____ stores definitions, such as data types for fields, default values, and validation rules for data in each field.
    13·1 answer
  • In reference to computer communications, what does the term noise mean?
    8·2 answers
  • Write a c program to count the total number of commented characters and words in a c file taking both types of c file comments (
    11·2 answers
  • 3. Write a program that prompts the user to input an integer that represents cents. The program will then calculate the smallest
    15·1 answer
  • Excerpt from "How Prepared Are Students for College Level Reading? Applying a Lexile-Based Approach."
    6·1 answer
  • at the grocery store alexa by 1 1/3 lb of ground turkey nasha by two times as much ground turkey is alexa how much ground turkey
    9·1 answer
  • when inserting a bibliography one choose from multiple ______ of bibliographies.[insert Bibliography]
    12·1 answer
  • Lattice-based access controls use a two-dimensional matrix to assign authorizations. What are the two dimensions and what are th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!