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
Write a C program that reads two hexadecimal values from the keyboard and then stores the two values into two variables of type
sattari [20]

Solution :

#include  $$

#include $$

#include $$

//Converts $\text{hex string}$ to binary string.

$\text{char}$ * hexadecimal$\text{To}$Binary(char* hexdec)

{

 

long $\text{int i}$ = 0;

char *string = $(\text{char}^ *) \ \text{malloc}$(sizeof(char) * 9);

while (hexdec[i]) {

//Simply assign binary string for each hex char.

switch (hexdec[i]) {

$\text{case '0'}:$

strcat(string, "0000");

break;

$\text{case '1'}:$

strcat(string, "0001");

break;

$\text{case '2'}:$

strcat(string, "0010");

break;

$\text{case '3'}:$

strcat(string, "0011");

break;

$\text{case '4'}:$

strcat(string, "0100");

break;

$\text{case '5'}:$

strcat(string, "0101");

break;

$\text{case '6'}:$

strcat(string, "0110");

break;

$\text{case '7'}:$

strcat(string, "0111");

break;

$\text{case '8'}:$

strcat(string, "1000");

break;

$\text{case '9'}:$

strcat(string, "1001");

break;

case 'A':

case 'a':

strcat(string, "1010");

break;

case 'B':

case 'b':

strcat(string, "1011");

break;

case 'C':

case 'c':

strcat(string, "1100");

break;

case 'D':

case 'd':

strcat(string, "1101");

break;

case 'E':

case 'e':

strcat(string, "1110");

break;

case 'F':

case 'f':

strcat(string, "1111");

break;

default:

printf("\nInvalid hexadecimal digit %c",

hexdec[i]);

string="-1" ;

}

i++;

}

return string;

}

 

int main()

{ //Take 2 strings

char *str1 =hexadecimalToBinary("FA") ;

char *str2 =hexadecimalToBinary("12") ;

//Input 2 numbers p and n.

int p,n;

scanf("%d",&p);

scanf("%d",&n);

//keep j as length of str2

int j=strlen(str2),i;

//Now replace n digits after p of str1

for(i=0;i<n;i++){

str1[p+i]=str2[j-1-i];

}

//Now, i have used c library strtol

long ans = strtol(str1, NULL, 2);

//print result.

printf("%lx",ans);

return 0;

}

4 0
2 years ago
US-CERT is a set of moderated mailing lists full of detailed, full-disclosure discussions and announcements about computer secur
n200080 [17]

Answer:

False

Explanation:

BugTraq is a high volume, full disclosure mailing list for the detailed discussion and announcement of computer security vulnerabilities, not US-CERT

3 0
2 years ago
Which technology can allow a single ground-based telescope to achieve images as sharp as those from the Hubble Space Telescope?
Ganezh [65]

Answer:

The correct answer to the following question will be "Adaptive Optics".

Explanation:

  • AO (Adaptive Optics) is a technique used to enhance optical system performance by reducing the impact of incoming gravitational wave distortions by compressing a mirror to compensate for the distortion.
  • It operates by calculating and compensating for defects in a wave-front with a system that corrects these errors as a deformable mirror or even a liquid crystal collection.
  • It is a technique that can make it possible for a single ground-based telescope to get images as clear as that of the Hubble Space Telescope.
  • Certain methods can achieve power resolution that exceeds the limit set by atmospheric distortion, for example, Aperture synthesis, Lucky imaging, and Speckle imaging.

Therefore, Adaptive Optics is the right answer.

7 0
3 years ago
In the Word 2016 window, where is the Status bar located?
Ludmilka [50]

Answer:

The Word status bar is displayed at the bottom of your document window. Just click it. You can customize if needed, just right click on the status bar.

Explanation:

6 0
3 years ago
modify hw 02 c.c to use envp instead of environ. be sure that you understand how the code works. provide liberal comments to exp
rjkz [21]

With the aid of pointer-based arithmetic operations and the usage of pointers in comparison operations, address arithmetic is a technique for determining the address of an object. Pointer arithmetic is another name for address arithmetic.

The pointers can be used for mathematical operations like addition, subtraction, etc. The outcome of an arithmetic operation on the pointer, however, will likewise be a pointer if the other operand is of type integer because we know that the pointer includes the address. These operations are addition and subtraction. In C++, a pointer's value can be increased or decreased. It signifies that we can change the pointer's value by adding or removing integer values. A pointer arithmetic can be subtracted (or added) from another in a manner similar to this.

Learn more about arithmetic here-

brainly.com/question/11424589

#SPJ4

4 0
1 year ago
Other questions:
  • Vpns create a _____________ to transport information through public communications media.
    8·1 answer
  • A hacker changing the ip addresses used in conjunction with a particular company’s web site to re-route them to the hacker’s ser
    11·1 answer
  • For a wire with a circular cross section and a diameter = 3.00mm calculate the following: (m means meter. mm means millimeter. c
    5·1 answer
  • You are configuring IP settings on a new network. For the external interfaces, you decide to obtain registered IP addresses from
    5·1 answer
  • The ________ option contains the formatting and placeholders for all of the items that appear on a side.
    11·1 answer
  • Select the correct answer.
    12·2 answers
  • PLEASE HELP
    5·1 answer
  • . How is using 0 / 1 or true / false in specifying digital an abstraction?
    11·1 answer
  • Give four advantages for ssd compared to hdd
    15·2 answers
  • Pls awnser if awnser is wrong I will unmark brainliest
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!