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
bagirrra123 [75]
3 years ago
6

Write an application that determines whether the first two files are located in the same folder as the third one. The program sh

ould prompt the user to provide 3 filepaths. If the files are in the same folder display All files are in the same folder, otherwise display Files are not in the same folder.
Computers and Technology
1 answer:
marissa [1.9K]3 years ago
5 0

Answer:

The program in Python is as follows:

fname1 = input("Filepath 1: ").lower()

fname2 = input("Filepath 2: ").lower()

fname3 = input("Filepath 3: ").lower()

f1dir = ""; f2dir = ""; f3dir = ""

fnamesplit = fname1.split("/")

for i in range(len(fnamesplit)-1):

   f1dir+=fnamesplit[i]+"/"

fnamesplit = fname2.split("/")

for i in range(len(fnamesplit)-1):

   f2dir+=fnamesplit[i]+"/"

fnamesplit = fname3.split("/")

for i in range(len(fnamesplit)-1):

   f3dir+=fnamesplit[i]+"/"

if f1dir == f2dir == f3dir:

   print("Files are in the same folder")

else:

   print("Files are in the different folder")

Explanation:

The next three lines get the file path of the three files

<em>fname1 = input("Filepath 1: ").lower()</em>

<em>fname2 = input("Filepath 2: ").lower()</em>

<em>fname3 = input("Filepath 3: ").lower()</em>

This initializes the directory of the three files to an empty string

f1dir = ""; f2dir = ""; f3dir = ""

This splits file name 1 by "/"

fnamesplit = fname1.split("/")

This iteration gets the directory of file 1 (leaving out the file name)

<em>for i in range(len(fnamesplit)-1):</em>

<em>    f1dir+=fnamesplit[i]+"/"</em>

This splits file name 2 by "/"

fnamesplit = fname2.split("/")

This iteration gets the directory of file 2 (leaving out the file name)

<em>for i in range(len(fnamesplit)-1):</em>

<em>    f2dir+=fnamesplit[i]+"/"</em>

This splits file name 3 by "/"

fnamesplit = fname3.split("/")

This iteration gets the directory of file 3 (leaving out the file name)

<em>for i in range(len(fnamesplit)-1):</em>

<em>    f3dir+=fnamesplit[i]+"/"</em>

This checks if the file directories hold the same value

This is executed, if yes

<em>if f1dir == f2dir == f3dir:</em>

<em>    print("Files are in the same folder")</em>

This is executed, if otherwise

<em>else:</em>

<em>    print("Files are in the different folder")</em>

You might be interested in
A _______________ is a security threat that may launch a worm through a Trojan horse or launch a denial-of-service attack at a t
lesantik [10]

Answer:

Malware

Explanation:

It has the following characteristics:

• They are the most common in the network, and the difference with computer viruses is that they do not need user intervention.

• has the characteristic of replicating itself to expand through the networks to which a device is connected.

• When entering a computer, the worm tries to obtain the addresses of other computers through your contact lists, to infect them as well.

• They do not have to manipulate any program or make the computer malfunction, which makes them a little more difficult to detect.

• Take into account that Malware is "malicious software".

 

8 0
3 years ago
Which command os used to find a particular word in a document ?<br>​
lorasvet [3.4K]

Answer:

Ctrl+F

EXPLANATION :

Press Ctrl+F, or click Find on the Home tab. Type the text string into the Find What box. Click Find In. On the menu that opens, click Main Document.

hope it helps you please mark me as brainliest

8 0
2 years ago
Read 2 more answers
Enhancement of job satisfaction and productivity are key characteristics of which theoretical perspective of work design? ​
Pavlova-9 [17]

Answer: Socio-technical systems

Explanation:

Sociotechnical systems refers to an approach to organizational work design whereby the interaction between people and technology in the workplace is recognized.

It should be noted that the welfare of the worker is emphasized in socio technical systems is emphasized in the form of motivation and job enrichment.

3 0
3 years ago
1. Why is photographing lightning a difficult process?
bulgar [2K]
<span>1. Why is photographing lightning a difficult process?
</span>Some reasons which come to my mind for saying this are: 1) You get only one chance for the particular situation - it is not like portrait photography where you can go back in the studio if the photos didn't come out well; 2) lightning varies so much in brightness, intensity and location that guessing the proper exposure requires a lot of experience, as well as luck; 3) you are always at some risk when photographing worthwhile lightning; and 4) lightning is a point (line) source, and demands the most of the optical quality of your camera 
<span>
2. What piece of equipment is helpful in capturing lightning photographs?
</span><span><span>SLR camera with B-shutter speed (preferably SLR; you might try using your digital camera, if it has B mode, but this is much more difficult)</span><span>lenses ranging from 28mm to 135mm at minimum. Fixed-focal lenses are preferred over zoomlenses. Aperture ranges should be f/2.8 - f/22.</span><span>sturdy tripod (metal or plastic doesn't make any difference whatsoever at all in safety - if lightning is so close by, you are in trouble anyway)</span><span>cable release, which can be locked</span><span>Slow-speed film: 100 or 200 ISO
</span></span><span>
3. Why is it important to mentally prepare for photographing lightning?
</span><span>When photographing lightning, it’s important to realize that the conditions you are shooting in are unpredictable and dangerous, and there will always be an element of chance and luck involved. So you should prepare yourself.
</span><span>
4. What time of day should you try to photograph lightning?
</span>Nighttime lightning photography is the easiest <span>type
</span><span>
5. Why is composition important in lightning photographs?
It boosts or adds drama to your picture. </span>
6 0
3 years ago
Read 2 more answers
The first computer introduced was the IBM PC. A. True B. False
Lerok [7]
The answer to your question is true
5 0
3 years ago
Read 2 more answers
Other questions:
  • Software license infringement is also often called software __________.
    11·2 answers
  • Enhancing and optimizing customer retention and loyalty is a major business strategy.
    15·1 answer
  • What is hyper transport
    10·1 answer
  • Which option will automatically update copied data?
    12·2 answers
  • When mapping a drive, you can type in the path to the shared folder on the host computer. what is the syntax for the path?
    7·1 answer
  • Melanie needs to ensure that readers are able to locate specific sections within a document easily. What should she include in
    8·1 answer
  • Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any ot
    10·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    15·1 answer
  • How do you fix this!!!!
    5·1 answer
  • you are currently logged in using the badams account. you want to view the contents of the /etc/inittab file, but you are not al
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!