answer.
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
Oksanka
2 months 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:
Amiraneli [1K]2 months ago
6 0

Answer:

Below is the complete code for this question:

import os #importing package

def parent_directory():#defining method parent_directory

   dir = os.getcwd()#storing current working directory in dir

   relative_parent = os.path.join(dir) #from dir, define relative_parent variable using join method

   return os.path.dirname(relative_parent)#return the directory name using return keyword

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

Output:

/

Note:

This program executes in an online compiler, hence it returns "/"

Explanation:

The provided Python code imports the "os" package, after which it defines a method called "parent_directory" that uses the variable dir to store the current working directory through the "getcwd" method.

  • Next, the variable "relative_parent" is defined, using the join method to store the directory value and returning its value.
  • Lastly, the print function is called to output the method's result.
You might be interested in
Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input.
Amiraneli [1052]

Answer:

In C++:

#include <iostream>

#include <string>

#include <sstream>

using namespace std;

int main(){

   string lname, fname, stringnum;    int num; string login, pwd;

   cout<<"Last Name: ";    cin>>lname;

   cout<<"First Name: ";    cin>>fname;

   cout<<"Four-digit integer: ";    cin>>num;

   stringnum = to_string(num).substr(0, 4);

   stringstream geek(stringnum);    geek>>num;

   num = num%100;

   pwd = to_string(num);

   if(lname.length()<5){ login = lname + fname.substr(0, 1);    }

   else{ login = lname.substr(0, 5) + fname.substr(0, 1);    }

   cout<<"Login Name: "<<login<<endl;

   cout<<"Password: "<<pwd<<endl;

   return 0;

}

Explanation:

This initializes all the required variables

   string lname, fname, stringnum;    int num;     string login, pwd;

This asks the user for their last name

   cout<<"Last Name: ";    cin>>lname;

This asks for the first name of the user

   cout<<"First Name: ";    cin>>fname;

This prompts for a four-digit number

   cout<<"Four-digit integer: ";    cin>>num;

This converts the number into a string and extracts the first four digits

   stringnum = to_string(num).substr(0, 4);

This changes the string back into an integer

   stringstream geek(stringnum);    geek>>num;

This extracts the last two digits of the four-digit number

   num = num%100;

This generates the user's password

  pwd = to_string(num);

This constructs the user's login name.

This block runs if the last name has fewer than five letters

   if(lname.length()<5){ login = lname + fname.substr(0, 1);    }

This block runs otherwise

   else{ login = lname.substr(0, 5) + fname.substr(0, 1);    }

This displays the login name

   cout<<"Login Name: "<<login<<endl;

This displays the password

   cout<<"Password: "<<pwd<<endl;

3 0
2 months ago
Which of the following describes ETL? a) A process that transforms information using a common set of enterprise definitions b) A
zubka84 [1067]

Answer:

The right choice is d) All of these options are accurate.

Explanation:

ETL refers to Extract, Transform, and Load. An ETL framework retrieves data from various sources, upholds standards for data quality and consistency, standardizes data so disparate sources can be integrated, and ultimately presents the data in formats suitable for application development and decision-making by end-users.

4 0
2 months ago
Andre is finding working in an online group challenging because there are people in the group from many different cultural backg
Harlamova29_29 [1022]

Answer:

Varied Communication Styles

Diverse Attitudes Toward Conflict

Different Methods for Completing Tasks

Various Decision-Making Approaches

Different Perspectives on Disclosure

Diverse Ways of Knowing

Explanation:

6 0
2 months ago
Read 2 more answers
Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
zubka84 [1067]
Answer: Sole Proprietorship. This question seeks to identify the business type mentioned in the scenario. In a Sole Proprietorship, the owner effectively is the business, managing all elements from operations to finance. Typically, this is the initial business form in entrepreneurship. The description fits Doug well; he operates the farming business independently, taking care of all its functions. Thus, it qualifies as a sole proprietorship.
5 0
1 month ago
Other questions:
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    11·2 answers
  • Remember for a moment a recent trip you have made to the grocery store to pick up a few items. What pieces of data did the Point
    10·1 answer
  • Users report that the network access is slow. After questioning the employees, the network administrator learned that one employ
    7·1 answer
  • Create a different version of the program that: Takes a 3-digit number and generates a 6-digit number with the 3-digit number re
    14·1 answer
  • RADIAC instruments that operate on the ionization principle are broken down into three main categories based on what?
    15·1 answer
  • Consider a one-way authentication technique based on asymmetric encryption: A --&gt; B: IDA B --&gt; A: R1 A --&gt; B: E(PRa, R1
    13·1 answer
  • A router has a valid operating system and a configuration file stored in nvram. the configuration file contains an enable secret
    10·1 answer
  • Haley is helping to choose members for a customer satisfaction team. Which of the following employees demonstrate skill in focus
    13·1 answer
  • There are two algorithms called Alg1 and Alg2 for a problem of size n. Alg1 runs in n2 microseconds and Alg2 runs in 100n log n
    13·1 answer
  • On January 1, 1980, Moises deposited $1850 into a savings account paying 5.6% interest, compounded quarterly. If he hasn't made
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!