Question

In: Computer Science

Given the names of employees in an office: employees = ["Matthew", "Anna", "Curtis", "Jane", "Yang", "Tammie"]...

Given the names of employees in an office: employees = ["Matthew", "Anna", "Curtis", "Jane", "Yang", "Tammie"]

Using the Random library in Python, create two codes that: A. Draws a random sample (without replacement) of 2 employees. Saves and displays the sample. B: Draws a random sample (with replacement) of 4 employees. Save and Displays the sample

Solutions

Expert Solution

A)

.

import random

# Given the names of employees in an office:

employees = ["Matthew", "Anna", "Curtis", "Jane", "Yang", "Tammie"]

# A. Draws a random sample(without replacement) of 2 employees.

first_sample = random.sample(employees, 2)

# Saves and displays the sample.

print(first_sample)

.

Screenshot:

Output:

.

B)

.

import random

# Given the names of employees in an office:

employees = ["Matthew", "Anna", "Curtis", "Jane", "Yang", "Tammie"]

# B: Draws a random sample(with replacement) of 4 employees.

second_sample = []

for i in range(4):

    second_sample += random.sample(employees, 1)

# Save and Displays the sample

print(second_sample)

.

Screenshot:

Output:

.


Related Solutions

You are given a list of all employees. You group the names by department (Logistics, Sales,...
You are given a list of all employees. You group the names by department (Logistics, Sales, IT, Human Resource). Suppose you select all employees in Sales. What type of sampling method did you use to select the employees? Explain your reasoning.
Anna is a 45-year-old female that presented to her physician’s office for her annual check-up. Anna...
Anna is a 45-year-old female that presented to her physician’s office for her annual check-up. Anna has a history of diabetes, obesity, and noncompliance with diet and medications to control her diabetes. She a single mother of three teenagers and smokes regularly. During the history review, Anna shares with you that she has not been feeling like herself for the past six months, she has been unusually tired and thought that she felt a lump in her right breast during...
Jane Freeman transferred three properties to Health Innovations Corporation: An office building, office equipment in that...
Jane Freeman transferred three properties to Health Innovations Corporation: An office building, office equipment in that building, and an adjacent parking garage, in a Sec. 351 exchange, as shown in the table below: Property Adjusted Basis FMV Office building $80,000 $110,000 Office equipment     2,000       1,500 Parking Garage     15,000     12,000 $ 97,000 $123,500 The garage and equipment are free of liabilities, but a $110,000 mortgage remains on the office building. Complete calculations and explain your answers to...
You are a manager and you want one of your employees to receive training. Anna is...
You are a manager and you want one of your employees to receive training. Anna is one your best workers and you believe one day she will have your job on her way to the c-suite. You know money is tight right now and if you don’t use your training budget (there is currently $2,000 left) by the end of the quarter the company will take it back. Also, you have heard rumors that the raise pool will be low...
Matthew needs a long-term mortgage to finance a new office building and is trying to decide...
Matthew needs a long-term mortgage to finance a new office building and is trying to decide between two loan proposals. Loan #1 is a 10-year term, 20-year amortization loan. Loan #2 is a 10-year term, interest-only loan. However, as is often the case, Matthew is very confused. He notes that both the upfront fee and contract mortgage rate are slightly higher with the interest-only loan compared to the partial amortization loan. As a result, Matthew feels this is backwards since...
The names of the employees of Hogan Thrift Shop are listed on the following payroll register....
The names of the employees of Hogan Thrift Shop are listed on the following payroll register. Employees are paid weekly. The marital status and the number of allowances claimed are shown on the payroll register, along with each employee's weekly salary, which has remained the same all year. Complete the payroll register for the payroll period ending December 22, the 51st weekly payday. The state income tax rate is 3.1% of total earnings, the city income tax rate is 1%...
The names of the employees of Hogan Thrift Shop are listed on the following payroll register....
The names of the employees of Hogan Thrift Shop are listed on the following payroll register. Employees are paid weekly. The marital status and the number of allowances claimed are shown on the payroll register, along with each employee's weekly salary, which has remained the same all year. Complete the payroll register for the payroll period ending December 21, the 51st weekly payday. The state income tax rate is 2% of total earnings, the city income tax rate is 1.5%...
The names of the employees of Hogan Thrift Shop are listed on the following payroll register....
The names of the employees of Hogan Thrift Shop are listed on the following payroll register. Employees are paid weekly. The marital status and the number of allowances claimed are shown on the payroll register, along with each employee's weekly salary, which has remained the same all year. Complete the payroll register for the payroll period ending December 21, the 51st weekly payday. The state income tax rate is 2% of total earnings, the city income tax rate is 1.5%...
Retrieve the names of employees whose salary is within $20,000 of the salary of the employee...
Retrieve the names of employees whose salary is within $20,000 of the salary of the employee who is paid the most in the company (e.g., if the highest salary in the company is $80,000, retrieve the names of all employees that make at least $60,000) Based on the following table: -- drop tables DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; DROP TABLE DEPARTMENT CASCADE CONSTRAINTS; DROP TABLE DEPT_LOCATIONS CASCADE CONSTRAINTS; DROP TABLE PROJECT CASCADE CONSTRAINTS; DROP TABLE WORKS_ON CASCADE CONSTRAINTS; DROP TABLE...
Jane Heinlein is the payroll accountant for Sia Lights of Carter, Nebraska. The employees of Sia...
Jane Heinlein is the payroll accountant for Sia Lights of Carter, Nebraska. The employees of Sia Lights are paid biweekly. An employee, Melinda Gunnarson, comes to her on September 14 and requests a pay advance of $825, which she will pay back in equal parts on the September 28 and October 12 paychecks. Melinda is single with one withholding allowance and is paid $32,500 per year. She contributes 1 percent of her pay to a 401(k) plan and has $25...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT