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
Which search strategy is most similar to greedy search?
lesya692 [45]

Answer:

I think the answer would be A.

Explanation:

If I'm wrong plz let me know (I think I may be wrong)

8 0
3 years ago
Which function can NOT be performed using the Conditional Formatting option?
Liono4ka [1.6K]

Answer:D is the answer to this one

5 0
3 years ago
Read 2 more answers
What type of program would you use to create a personal budget?
ira [324]

Answer:

using Excel is the easiest way to create and use a budget, based on the formulas you can create to have the budget do the work for you, instead of vice versaExplanation:

6 0
2 years ago
INTRODUCTION TO JAVA​
amid [387]

Answer:

INTRODUCTION TO JAVA​

Explanation:

Java is one of the most popular programming languages out there. Released in 1995 and still widely used today, Java has many applications, including software development, mobile applications, and large systems development. Knowing Java opens a lot of possibilities for you as a developer.

5 0
3 years ago
What finger is used to key letter c
kumpel [21]

Answer:

your pointer finger

sorry if this is wrong

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • 3.6 lesson practice
    12·1 answer
  • What is the key benefit of using RAM in a computer?
    12·1 answer
  • When you ask the database more complex questions using comparison operators, you are conducting a _____. sort questionnaire quer
    7·1 answer
  • Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and sec
    7·1 answer
  • What approach to dealing with deadlock does the wait-for graphs implement (prevention/avoidance/detection/ recovery)?
    6·1 answer
  • Explain with a few sentences and using the terms sequencing, selections and loops how they
    9·1 answer
  • The capacity of a communication channel is measured in _______.
    6·2 answers
  • Write a program that include a method that returns the sum of all the elements of a Linked List of Integers. Allow the user to e
    11·1 answer
  • write a java program that prompts the user to enter scores (each number an integer from 0 to 10) and prints the following output
    13·1 answer
  • What is the difference between EPROM and EEPROM, explain why​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!