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
-Dominant- [34]
3 years ago
10

The parent_directory function returns the name of the directory that's located just above the current working directory. Remembe

r that '..' is a relative path alias that means "go up to the parent directory". Fill in the gaps to complete this function.
import os
def parent_directory():
# Create a relative path to the parent
# of the current working directory
dir = os.getcwd()
relative_parent = os.path.join(dir, ___)
# Return the absolute path of the parent directory
return os.path.dirname(relative_parent)
print(parent_directory())
Computers and Technology
1 answer:
dedylja [7]3 years ago
6 0

Answer:

Following are the complete code to this question:

import os #import package  

def parent_directory():#defining a method parent_directory

   dir = os.getcwd()#defining dir that stores the getcwd method value  

   relative_parent = os.path.join(dir) #defining relative_parent variable that uses join method to adds directory

   return os.path.dirname(relative_parent)#use return keyword to return directory name

print(parent_directory())#use print method to call parent_directory method

Output:

/

Note:

This program is run the online compiler that's why it will return "/"

Explanation:

In the given Python code, we import the "os" package, after that a method "parent_directory" is defined, which uses the dir with the "getcwd" method that stores the current working directory.  

  • After that "relative_parent" variable is declared, which uses the join method to store the directory value and use the return keyword to returns its value.  
  • In the next step, the print method is used, which calls the method.
You might be interested in
The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per se
german

Answer:

The Java Program for the given problem is as below. Directly copy the code and run it on your machine.

Explanation:

Refer the Screenshots attached for the output.

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class TheSpeedOfSound {

public static void main(String[] s)

{

String medium;

double distance;

double time;

try{

BufferedReader choice = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter one of the following: air, water, or steel: ");

medium = choice.readLine(); // reading input i.e. air, water or steel

//check for air water and steel

if (medium.equalsIgnoreCase("air") || medium.equalsIgnoreCase("water") || medium.equalsIgnoreCase("steel")){

System.out.println("Enter the distance the sound wave will travel: ");

distance = Double.parseDouble(choice.readLine()); // read distance value if it is air water or steel

switch (medium)

{

//if medium is air

case "air":

time = distance/1100;

System.out.print("It will take " + time + " seconds.");

break;

//if medium is water

case "water":

time = distance/4900;

System.out.print("It will take " + time + " seconds.");

break;

//if medium is steel

case "steel":

time = distance/16400;

System.out.print("It will take " + time + " seconds.");

break;

}

}

else{

System.out.print("Sorry, you must enter air, water, or steel.");  

}

}

catch(Exception e){

e.printStackTrace();

}

}

}

8 0
3 years ago
Which popular file format loses some of the information from the image? JPEG TIFF RAW NEF
lisov135 [29]

Answer:

The popular file format that loses some of the information from the image is JPEG

Explanation:

4 0
2 years ago
Hello can you please help with this if you want to thank you!
nikklg [1K]

Answer:

hardware and software is the answer

8 0
2 years ago
Read 2 more answers
Select the correct answer.
miv72 [106K]

Answer: Format

Explanation: My head

3 0
2 years ago
Read 2 more answers
1. what is the purpose of giving an id to an html element when using javascript?
bazaltina [42]

Answer:

It is also used by JavaScript to access and manipulate the element with the specific id.

3 0
2 years ago
Other questions:
  • ) The ________ displays a text box and button for users to browse, select, and upload a file. (Points : 3)
    13·1 answer
  • Your company is implementing a wireless network and is concerned that someone from a competing company could stand outside the b
    14·1 answer
  • Your friend sees an error message during Windows startup about a corrupted bootmgr file. He has another computer with a matching
    12·1 answer
  • In the MOV instruction both operands i.e. source andthe destination cannot be
    15·2 answers
  • Encapsulation is the process of “packaging” information prior to transmitting it from one location to another. true or false
    14·1 answer
  • Number Array Class
    5·1 answer
  • 2 Manter o autocontrole nos ajuda a evitar muitos problemas na nossa vida pessoal e no ambiente profissional. Em se tratando de
    14·1 answer
  • Using Microsoft Word, write a 250-word essay on the fading of home telephone use with the advent of recent technology, and share
    14·1 answer
  • What is the way to discover requirments for software projects ?
    14·1 answer
  • Why do computers use binary code?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!