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
sergij07 [2.7K]
3 years ago
3

Write a code segment that prompts the user for a filename. If the file exists, the program should print its contents on the term

inal. Otherwise, it should print an error message.
Computers and Technology
1 answer:
Sergio039 [100]3 years ago
7 0

Answer:

Code is written in Python

dataobject = DataTransferinFiles()

Should be just:

dataobject = DataTransferinFiles()

So the full code:

class DataTransferinFiles():

def transfer(self,firstfilename,secondfilename):

print("your first file is=",firstfilename);

print("your second file is =", secondfilename)

with open(firstfilename,'r')as filedata:

firstfiledata= filedata.readlines()

print()

print("1st file reading complete")

print()

with open(secondfilename, 'r')as filedata:

secondfiledata=filedata.readlines()

print("2st file reading complete")

for eachline in firstfiledata:

filesecond = open(secondfilename,'a')

filesecond.write("/n"+eachline+ "/n")

print ("1st file transfered in to second file")

for eachline in secondfiledata:

filefirst = open(firstfilename)

filefirst.write("\n"+eachline+ "\n")

print ("second file transfered in to first file")

dataobject = DataTransferinFiles()

firstfilename = input("enter first file name for transfer")

secondfilename = input("enter second file name for transfer")

dataobject.transfer(firstfilename,secondfilename)

You might be interested in
What are entity-relationship diagrams and how are they used? What symbol is used for a relationship? What is an associative enti
castortr0y [4]

Answer:

The definition including its given problem is outlined in the following segment on the clarification.

Explanation:

  • Entity-relationship (ER) diagram describes how mechanical stored procedures are constructed and demonstrate the overarching representation of the situation. It also describes the connections between some of the entities of the framework and even the comparison with standard measurements.
  • For something like an individual relationship structure, the normal representation of connections seems to be a diamond. Associative institutions have several to many partnerships to communicate with. It's indeed the verb throughout a diamond-shaped form that holds two organizations around each other. This verb is in fact an entity on its own, therefore it must be termed an associative entity.
  • An illustration of such might be if a participant were to register for a class. Multiple individuals will be registered for several courses, and there have been many to several relationships; thus, the associative object will indeed register.
4 0
3 years ago
The Go To feature can be accessed from which of the following dialog boxes?
Aliun [14]

Answer:

hoose the answer.

•Font

•Open

•Insert Hyperlink

Explanation:

4 0
3 years ago
What are the four main types of section breaks? Check all that apply.
Romashka-Z-Leto [24]
The answer would be next page, continuous, even page, and odd page.
5 0
3 years ago
Read 2 more answers
You just purchased a single license for the latest Microsoft Office Suite. Your friend has asked to borrow the CD, so he can ins
TiliK225 [7]

Answer:

B

Explanation:

No, this would be piracy. If he would want to install it, he would have to buy it himself.

Hope this helps :D

6 0
3 years ago
Is the process of modifying something to make it fit certain criteria.
alexandr402 [8]

Answer:

Design Process

8 0
3 years ago
Other questions:
  • . Consider the following brute-force algorithm for evaluating a polynomial. ALGORITHM Brute Force Polynomial Evaluation(P[0..n],
    14·1 answer
  • To reach fifty million users, it took _____.
    10·2 answers
  • NEED ASAP!!
    14·1 answer
  • The Mail Merge option is located in which tab? a;home b;insert c;refernces d;mailings
    11·2 answers
  • In the ______ algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the
    11·1 answer
  • Implement the Dining Philosophers problem (described on pages 167-170 in the textbook (chapter 2.5.1)). Create a Graphical User
    13·1 answer
  • What is the first step you should take when you want to open a savings account make your initial deposit go to the bank and fill
    9·1 answer
  • How am i supposed to add subtitles to a video without have to waist money???
    7·1 answer
  • PLEASE HELP ME ASAP ITS IMPORTANT
    8·2 answers
  • I will give brainliest to the best answer. what is a good screen recorder
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!