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
In the URL, what is the subdomain and what is the domain name?
timurjin [86]

<u>Answer</u>:

<u>EXAMPLES:</u>

Primary domain name could be “bestwebdesigner.com,”

subdomain to that domain called “blog.bestwebdesigner.com.”

<u>Explanation</u>:

Essentially, a subdomain is a separate part of your website that operates under the same primary domain name.

5 0
3 years ago
What are your strongest competencies? What will you do them? <br>❌NONSENSE ANSWER<br>​
Anna [14]

Answer:

1. Teamwork

2. Responsibility

3. Commercial Awareness

4. Decision Making

5. Communication

6. Leadership

7. Trustworthiness & Ethics

8. Results Orientation

9. Problem Solving

10. Organisational skills

8 0
2 years ago
Which access control principle specifies that no unnecessary access to data exists by regulating members so they can perform onl
sdas [7]
Least privilege is the data access principle that ensures to unnecessary access to data exists by regulation members so that can perform only minimum data manipulation necessary. The principle of least privilege or as called as POLP is the run-through of controlling access to the minimal level that will permit normal functioning. The norm of least privilege interprets to giving people the lowermost level of user right that they can have and still do their jobs. The principle is also functional to things other than people as well as programs and processes. It is created in the US department of defense in the 1970’s and aimed to limit the potential damage of any security breach either accidental or malicious. 
5 0
3 years ago
Freeeee BRAINLIESTHBJHBJHB
andre [41]

Answer:A lot of people cry when they cut an onion. The trick is not to form an emotional bond.lol

4 0
3 years ago
Read 2 more answers
Answer this crossword for brainliest and 15 points
nordsb [41]

Answer:

I like ur cut G

Explanation:

6 0
3 years ago
Other questions:
  • you want to discard your old computer ,want to securely erase that data from your hard drive. what can you use to do this and wh
    12·1 answer
  • How is a Personal Fact Sheet used? a. A Personal Fact Sheet is a tool used to market yourself and build your network b. A Person
    13·2 answers
  • What does “int” means in php code
    13·1 answer
  • Explain the function of the Ribbon in Microsoft Word.
    15·1 answer
  • The main parts of a lever are the....
    6·2 answers
  • You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, an int variable nZips
    10·2 answers
  • Is it safe to take apart a computer monitor?
    13·1 answer
  • Sally has 4 quarters, 2 dimes, 6 nickels, and 10 pennies.
    13·2 answers
  • How do i change the default setting in word to no open in dark mode
    8·1 answer
  • The most significant concerns for implementation of computer technology involve _______, security, and ethics. accuracy property
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!