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
TEA [102]
3 years ago
11

The groups_per_user function receives a dictionary, which contains group names with the list of users. Users can belong to multi

ple groups. Fill in the blanks to return a dictionary with the users as keys and a list of their groups as values.
def groups_per_user(group_dictionary):
user_groups = {}
# Go through group_dictionary
for ___:
# Now go through the users in the group
for ___: # Now add the group to the the list of
# groups for this user, creating the entry
# in the dictionary if necessary
return(user_groups)
print(groups_per_user({"local": ["admin", "userA"],
"public": ["admin", "userB"],
"administrator": ["admin"] }))
Computers and Technology
1 answer:
Akimi4 [234]3 years ago
3 0

The groups_per_user function receives a dictionary, which contains group names with the list of users.

Explanation:

The blanks to return a dictionary with the users as keys and a list of their groups as values is shown below :

def groups_per_user(group_dictionary):

   user_groups = {}

   # Go through group_dictionary

   for group,users in group_dictionary.items():

       # Now go through the users in the group

       for user in users:

       # Now add the group to the the list of

         # groups for this user, creating the entry

         # in the dictionary if necessary

         user_groups[user] = user_groups.get(user,[]) + [group]

   return(user_groups)

print(groups_per_user({"local": ["admin", "userA"],

       "public":  ["admin", "userB"],

       "administrator": ["admin"] }))

You might be interested in
Imagine that you wanted to write a program that asks the user to enter in 5 grade values. The user may or may not enter valid gr
OLEGan [10]

Answer:

B. A "while" loop inside of a "for" loop

Explanation:

To enter 5 grade values, a for loop can be used to specify the number of grade values to be entered by the user, in other to ensure the validity of the grade values entered by the user, the while loop will be used inside the for loop such that the inputted values will only be accepted when the user enters a valid grade.

Code structure :

For a in range(0, 5) :

grade = input()

while grade (enter condition)

This is just the code structure and this will work for the problem stated.

5 0
2 years ago
Which Internet resource can you use to publicly describe an adventure trip you recently made?
olasank [31]
If your planning on going social Facebook is the way to go ! But for most people you may decide to post anonymously so ! Search "Anonymous Posts" on google and their should be many websites you can anonymously tell you trips and embarrassing experiences safely on :)
8 0
2 years ago
The ________ is the easy way to insert a new slide between existing slides.
Tema [17]
What is the subject about?
7 0
3 years ago
E-mail has made it very easy to send a message to more than one person at any time of day from just about anywhere. If you wante
lana66690 [7]
You should send a Carbon Copy to your manger. You would type your manager's email into the slot next to cc.
5 0
3 years ago
What is DAP? How LDAP is different from DAP?
lions [1.4K]

Answer: DAP stands for directory access protocol .It is a protocol that is used for accessing the information from the directory of X.500 protocol.

LDAP(Lightweight directory access protocol) is the software protocol that is present for the simplification process of the X.500 protocol and to make it light-weighted .It is basically a version of DAP in a lightweight form.

8 0
3 years ago
Other questions:
  • Declare a character variable letterStart. Write a statement to read a letter from the user into letterStart, followed by stateme
    12·1 answer
  • How to turn a flash drive into a bluetooth adapter?
    13·1 answer
  • Given the following code segment, what is output after "result = "? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout <<
    7·1 answer
  • Write a method reverse( ) for OurLinkedList class. The method should return a new OurLinkedList object that is the reverse of th
    8·1 answer
  • Write a function called activity which takes an integer parameter X that does the following:
    6·1 answer
  • What is the analysis stage in System development life cycle?
    12·1 answer
  • Secops focuses on integrating the need for the development team to provide iterative and rapid improvement to system functionali
    14·1 answer
  • Write a class "Dog" with a private int field called months and two public member functions setAge and GetStage. setAge takes as
    13·1 answer
  • Four major parts of the keyboard
    12·2 answers
  • Which similar computer network components connect multiple devices?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!