Question: #Import the random module #create a dictionary called payroll _ entry inside a function. Name your function create _ payroll _ entry. You need to

#Import the random module
#create a dictionary called payroll_entry inside a function. Name your function "create_payroll_entry". You need to return the dictionary.
#This dictionary will contain no values, only keys - so for every value, you will want to code an empty string. For example: {'key': ''}
#Your dictionary should contain 5 main keys ('employee_id': 'payroll_details:' 'employee_info': 'department': 'bank_info': )
#The FIRST key "employee_id" is like any other key value pair, so list the key and the empty string '' as the value.
#The keys "IN ORDER" (payroll_details, employee_info, department, bank_info, will all contain other dictionaires as values). For example: {'key': {'key': 'value', 'key': 'value'}}
#'payroll_details': dictionary keys are salary and pay_rate (both with empty strings as values)
#'employee_info': dictionary keys are first_name, middle_initial, last_name, street_address, city, state, zip, position (all with empty strings as values)
#'department': dictionary keys are department_name, location, (all with empty strings as values)
#'bank_info': dictionary keys are account_number, routing_number (all with empty strings as values)
#The above instructions might look like the following structure. You will replace "key" with the appropriate key:
#Function Declaration - USE THE FOLLOWING DICTIONARY STRUCTURE. Your first key is employee_id with the empty string as the value. Adjust for more or less number of key-value pairs where needed.
'''payroll_entry ={
'user_id': '',
'key': {'key': '', 'key': ''},
'key': {'key': '', 'key': '', 'key': '',},
'key': {'key': '', 'key': '', 'key': '',},
'key': {'key': '', 'key': '', 'key': '', 'key': '',},
'key': {'key': '', 'key': ''},
}'''
#Return Statement RETURN THE DICTIONARY HERE.
#After creating your dictionary function, Define a parameterized funtion called "get_employee_info", you can simply use 'employees' as your parameter.
#Inside your new function:
#2. Inside the 'get_employee_info' function:
#3. Print a message to prompt the payroll clerk to create a new employee account.
#4. Generate a random 10-digit number (user_id) between 1000000000 and 9999999999.
#5. Convert the generated random number to a string and assign it to the 'employee_id' key in the 'employees' dictionary.
#6. Iterate through each key-value pair in the 'employees' dictionary using a loop.
#7. For each key in the dictionary:
#Check if the key is not equal to 'employee_id'.
#If it's not 'employee_id', print the key as a category (e.g., 'payroll_details', 'department').
#8. For each subkey within the current category:
#Prompt the user for input related to that subkey (e.g., if the category is 'payroll_details', prompt for 'salary' or 'pay_rate'). You'll need a conditional here (salry or payrate?)
#9. Update the corresponding subkey in the 'employees' dictionary with the payroll clerk's input.
#10. Repeat steps 8-11 for each key and subkey combination in the dictionary.
#11. After collecting all employee information, return the 'employees' dictionary from the 'get_employee_info()' function.
#12. Call the create_payroll_entry() function.
#13. Store the returned dictionary in a variable, such as 'new_employee'.
#14. Call the get_employee_info() function passing as an argument your "new_employee" dictionary reference
#15. print(new_employee)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!