CS Homework 4 Employee Ranker. Due: Wednesday, February 8th, before 11:55 PM Out of 100 points. Files to submit: 1. HW4.py.

Similar documents
CS Homework 4 Lifeguard Employee Ranker. Due: Tuesday, June 3rd, before 11:55 PM Out of 100 points. Files to submit: 1. HW4.py.

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 2316 Homework 9a GT Room Reservation Login

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

CS 2316 Pair 1: Homework 3 Enigma Fun Due: Wednesday, February 1st, before 11:55 PM Out of 100 points

CS 2316 Individual Homework 5 Joint Probability Out of 100 points

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points

This homework has an opportunity for substantial extra credit, which is described at the end of this document.

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, September 8th, before 6 PM Out of 100 points

CS 2316 Homework 9a Login Due: Friday, November 2nd, before 11:55 PM Out of 100 points. Premise

CS 2316 Homework 9a GT Pizza Login Due: Wednesday November 6th Out of 100 points. Premise

CS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points

CS 1803 Pair Homework 10 Newsvendor Inventory Policy Due: Monday, November 29th before 6:00 PM Out of 100 points

CS 2316 Homework 9b GT Room Reservation

CMSC 201 Fall 2016 Homework 6 Functions

CS 1301 Pair Homework 4 Conditionals & Loops Due: Friday, October 1, before 6 PM Out of 100 points

CS 1301 Individual Homework 3 Conditionals & Loops Due: Monday February 8 th before 11:55pm Out of 100 points

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, January 20 th, before 11:55 PM Out of 100 points

CS 1301 Homework Robot Web Writer

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 PM Out of 100 points

MATH 1MP3 Homework #4 Due: 11:59pm, Wednesday, March 6.

Visit the TA Helpdesk (schedule posted on class website)

CPSC 217 Assignment 4

CSCI 320 Group Project

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

CS 1301 Pair Homework 2 Conversions Due: Monday January 27th, 2014, before 11:55pm Out of 100 points Files to submit: hw2.py

CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings)

15-110: Principles of Computing, Spring 2018

Functional Programming, Classes, and Recursion!

CMSC 201 Spring 2018 Project 3 Minesweeper

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

Homework 1. Notes. What To Turn In. Unix Accounts. Reading. Handout 3 CSCI 334: Spring, 2017

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

CMSC 201 Spring 2018 Lab 01 Hello World

CMSC 201 Spring 2017 Lab 01 Hello World

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

by the evening of Tuesday, Feb 6

Homework 6: Higher-Order Procedures Due: 10:00 PM, Oct 17, 2017

Computer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:

Preparing for the Assistant Laboratory Animal Technician (ALAT) Certification Exam. University Laboratory Animal Resources

Operating Systems (234123) Spring (Homework 3 Wet) Homework 3 Wet

Claremont McKenna College Computer Science

61A Lecture 3. Friday, September 5

CSC148: Week 1

CMSC 201 Spring 2016 Homework 7 Strings and File I/O

Homework 1. Reading. Problems. Handout 3 CSCI 334: Spring, 2012

Abstract Data Types. CS 234, Fall Types, Data Types Abstraction Abstract Data Types Preconditions, Postconditions ADT Examples

Guide to setting up and using your NOW: Pensions payroll bureau microsite

File Operations. Working with files in Python. Files are persistent data storage. File Extensions. CS111 Computer Programming

CMSC 201 Spring 2017 Lab 12 Recursion

MIT AITI Python Software Development

CS 3030 Scripting Languages Syllabus

COMP 412, Fall 2018 Lab 1: A Front End for ILOC

Lecture 1. Course Overview, Python Basics

Due Sunday November 12th, 11:59pm. Project Basics document (part of assignment):

File Operations. Working with files in Python. Files are persistent data storage. File Extensions. CS111 Computer Programming

Assignment: 2. CS 135 Winter 2018 Graham, Nijjar

S206E Lecture 19, 5/24/2016, Python an overview

a b c d a b c d e 5 e 7

Data Entry Handbook DRIVER EDUCATION REIMBURSEMENT WEB APPLICATION. Online at:

Data Structures and Algorithms

Homework 2. Due 4:00pm, Wednesday, February 13, Installation and Handin 2

CMSC 201 Spring 2017 Lab 05 Lists

Python Review IPRE

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018

CS2304 Spring 2014 Project 3

CMSC 201 Computer Science I for Majors

ECE Object-Oriented Programming using C++ and Java

Individual Homework- Create Your Own Password! Due: September 15 th, 2014 Before 11:55PM Out of 100 points

Welcome to Blackboard

CSE : Python Programming. Homework 5 and Projects. Announcements. Course project: Overview. Course Project: Grading criteria

Repetition CSC 121 Fall 2014 Howard Rosenthal

Test Results Schedule Miscellanea Control Structs. Add l Oper s Break Hands on Q & A Conclusion References Files

Project 1. due date Sunday July 8, 2018, 12:00 noon

CMSC 201 Spring 2017 Project 1 Number Classifier

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

CSE 504: Compiler Design

Math 180 Written Homework Solutions Assignment #1 Due Thursday, September 4th at the beginning of your discussion class.

Orientation for Online Students

CLOVIS WEST DIRECTIVE STUDIES P.E INFORMATION SHEET

CMSC 201 Spring 2019 Lab 06 Lists

4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CSC343 Fall 2007 Assignment 2 SQL and Embedded SQL

CIS192: Python Programming

CS 211 Programming Practicum Fall 2018

A guide to setting up and using your NOW: Pensions Trust bureau microsite. Bureau user guide v2 PM /5

Lab 11 - Arrays, Searching and Sorting Directions

CS Lecture 19: Loop invariants

Repe$$on CSC 121 Fall 2015 Howard Rosenthal

Python Review IPRE

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

Problem Solving for Intro to Computer Science

LAB 4.1 Relational Operators and the if Statement

Lecture 1. Course Overview Types & Expressions

CS 302: Introduction to Programming in Java. Lecture 9

Week 3 Web site:

Transcription:

CS 216 Homework 4 Employee Ranker Due: Wednesday, February 8th, before 11: PM Out of 0 points Files to submit: 1. HW4.py This is an INDIVIDUAL assignment! Collaboration at a reasonable level will not result in substantially similar code. Students may only collaborate with fellow students currently taking CS 216, the TA's and the lecturer. Collaboration means talking through problems, assisting with debugging, explaining a concept, etc. You should not exchange code or write code for others. For Help: - TA Helpdesk Schedule posted on class website. - Email TA's or use T-Square Forums Notes: Do not forget to include the required comments and collaboration statement (as outlined on the course syllabus). Do not wait until the last minute to do this assignment in case you run into problems. Read the entire specifications document before starting this assignment. Premise The Supervisor at the Aquatics department needs to schedule time slots to lifeguards every week according to their availability. To do this efficiently and fairly, they hired an Industrial Engineer to devise a ranking system for priority. He worked with them over the summer and suggested that each employee be given a score for ranking purposes. The IE who devised the system graduated after the summer, and now the Aquatics Department has hired you to write python code to rank all the employees from the CSV data they have. The IE left you a detailed report of the ranking scheme and how the program should be coded. The ranking scheme is as follows: The Rank score of a lifeguard are based on categories: Position score, Supervisor evaluation score, and Peer evaluation score. Position Score: The employee has one of three positions, and receives corresponding points as follows - o New Lifeguards are employees that have been employed for less than a semester (112 days). New Lifeguards get points as their Position score. o Lifeguards are employees that have been employed for 1 semester or more (112 days or more). Lifeguards get 1 points as their Position score. o Head Guards are employees that have been employed for at least a year (6 days or more). Head Guards get 20 points as their Position score.

Peer Evaluation Score: A score given to each employee by their peers and ranges from 0 to points. Supervisor Evaluation Score: A score given to each employee by their supervisor and ranges from 0 to points. The Rank Score is calculated by simply adding up the scores. [Rank score = Position score + Supervisor evaluation score + Peer evaluation score] The higher the score, better the rank. The employee with the highest score will be awarded rank 1, the next highest will be rank 2, and so on. If employees have the same rank score, you should decide their rank as follows: o The employee who has been employed the longest should be ranked higher. o If the workers were employed on the same date, compare the Supervisor Evaluation Score. The employee with the higher Supervisor Evaluation Score should be ranked higher. o If they were employed on the same day and have the same Supervisor evaluation score, compare their GTIDs. The employee with a larger GTID value should be ranked higher. [Note that if they were employed on the same day, have the same Supervisor evaluation, and are in conflict, it means that they have the same Peer evaluation score, so we can't use the Peer evaluation score to de-conflict.] Program specifics The data will be provided to you in CSV format and it will change every month as lifeguards are promoted and scored by their peers and supervisors. SE score is the Supervisor Evaluation Score, PE score is the Peer Evaluation score, and Days being the Days since employment, the CSV file will have data in the following format: GTID, Last Name, First Name, SE score, PE score, Days An example record would be: 9024678, Burdell, George, 9,, 20 You have to parse the data into a list of lists in the following format: [ [ (GTID, Last name, First name), SE score, PE score, Days], ] An example of the inner list (representing each employee) inside the list (that stores all employees) would be: [ (9024678, Burdell, George ), 9,, 20 ] The (GTID, Last name, First name) is a tuple inside each list record.

At this point, you should calculate the Rank Score for each employee and start ranking them, resolving the conflicts of any employees that might have the same Rank score according to the rules mentioned above. As you give ranks to the employees, they should be stored in a dictionary using the rank as the key and a list with the following information as the value: [ (GTID, Last Name, First name), Position ] This list has two items, a tuple that represents the lifeguard (gtid, lastname, firstname) and their title/position. Example: Dictionary[4] [ (9024678, Burdell, George ), Lifeguard ] Once you have ranked them and created the dictionary, you should write the records to a new CSV file called employeeranks.csv in the following format: Rank, GTID, Last Name, First name, Position Example record that you write out to the file would be: 4, 9024678, George, Burdell, Lifeguard You will be writing the following functions: 1. parserecord 2. readcsvfile. getpositionscore 4. rankemployees. writecsvdata 6. employeeranker Plus any helper functions that you may decide to create and use. You are not required to use helper functions, but you are encouraged to do so if it makes your primary functions easier to understand. Function Name: parserecord string A string which contains one record (one line) from the file. list the data structure containing the employee information after adding the new record.

Write a function that will accept a string parameter which contains the contents of the one line from the file you are reading in the function readcsvfile(). This function will parse the given string from comma separated values into a list of the following format: [ (GTID, Last name, First name), SE score, PE score, Days] Note that the GTID, SE Score, PE Score, and Days entries will need to be converted to an integer, while the Last name and First Name should stay as strings. You should strip any leading or trailing whitespace from the strings. The GTID, Last name and First name are in a tuple. This list is a record of one employee and has to be returned by this function. If the data format of this line is invalid (not all data for the employee exists), you should raise a ValueError with a: raise ValueError statement. This value error will be handled by the employeeranker function. Function Name: readcsvfile none list the data structure containing the employee information in the above mentioned format. Write a function that will ask the user for a valid CSV file to read (for example, employeeinfo.csv ). In the event that the user provides an invalid file name or the file doesn t open, you should print a message such as Invalid file name and prompt the user to enter another valid file name. You should force the user to enter a valid filename until the file successfully opens. Your function will then read in this file and call parserecord on each line to parse the information contained within that line. You must call parserecord inside of readcsvfile to parse each line of the file. Create the new list of records that will be returned by this function. Each record that is returned (as a list) by parserecord should be appended to this list. The list that is to be returned should be a collection of lists that represent individual lifeguard records. Remember to close the file when you re done reading in the information. You may not use the CSV reader module; you must implement CSV reading yourself. Function Name: getpositionscore int Number of days the employee has been employed for. tuple Tuple containing the employee s position and its corresponding score Write a function that takes in the days of employment of an employee and finds the corresponding position of the employee. The position of an employee can be one of the following: New Lifeguard, Lifeguard, and Head Guard. New Lifeguards are employees

that have been employed for less than 112 days and get points as their position score. Lifeguards are employees that have been working for 112 days or more and get 1 points as their position score. Head guards have worked for 6 days or more and get 20 points as their position score. You should return the employee s position and its corresponding score in a tuple of the format ( New Lifeguard, ) (if the employee has worked for less than 112 days). Function Name: rankemployees list a data structure containing employee records. Dictionary a data structure containing ranks and employee information. Write a function that will accept the list that contains employee information as a collection of lists obtained after reading the file, as a parameter. Use the contents of each record in the list to calculate the Rank Score of each employee. The getpositionscore function should be helpful in calculating the Rank Score. You should then rank all the employees. Be sure to resolve all conflicts where two employees have the same Rank Score according to the rules given above. No two employees can have the same rank. The details of how you want to resolve the conflicts and where you want to store the rank scores are up to you. You may use the dictionary while you are ranking employees, or transfer the data to the dictionary after you have finished ranking them. You are most welcome to use any helper functions that may assist you in ranking the employees and resolve the conflicts. Create a new empty dictionary with the key as Rank (not to be confused with Rank Score), in the following format: Rank [(GTID, Lastname, Firstname), Position ] Notice, (GTID, Lastname, Firstname) is still a tuple. Rank, which is a key in the dictionary, is an integer value starting with 1. You will need to use the Position score given in the list to compute the Position of employee that you need to store in the dictionary. Once your dictionary is complete, you should return it. Note that the Position is a textual label, not a position score (number). Function Name: writecsvdata Dictionary the data structure that contains the ranks and the employee information. None

Write a function that will accept one parameter that is a dictionary with key as Rank of each employee. The dictionary would have the following format: Rank [ (GTID, Lastname, Firstname), Position ] Use this information to write all the records of this dictionary into a CSV file called employeeranks.csv in the following format: Rank, GTID, Last Name, First name, Position Order the records starting at the employee with the smallest rank (1) and moving up in rank as you write the file until you have written out the details for all of the employees. Remember to close the file when you re done writing in the information. Function Name: employeeranker None Bool True if everything went smoothly, or False if their was an error reading or writing files. This is the main function or the driver function of this Ranking code that will make calls to some of the other functions. Your TA will call this function to test your code. This function essentially makes calls to readcsvfile, rankemployees, and then writecsvdata. There are no parameters, but you must return True if the code ran without any problems. If there was an error while reading the file, writing the file, or in the formatting of the given data, the code should not crash. Instead, you should use try and except at various points in this method to make sure all the possible errors are caught. If an error is encountered, return False. (You do NOT have to recover from an error other than if the user enters an invalid file name.)

Testing your Code: Read from the attached file: employeedata1.csv Your output CSV file should look like the attached file: employeeranks1.csv You may create your own CSV data and experiment with your code, as our test data may not exercise all possible situations. Grading: You will earn points as follows for each function that works correctly according to the given specifications. parserecord Properly handles invalid strings by raising a value error Records correctly formatted data into the list with a tuple inside 7 readcsvfile 2 Properly handles invalid files Properly reads multi-line data Properly passes each line into parserecord function Formats and appends the records correctly into a list that is returned Closes file before exiting function getpositionscore Returns the correct position Returns the correct position score 2 rankemployees 0 Correctly computes the Rank Score of each employee Calculates the ranks correctly taking care of all conflicts Correctly creates and returns the dictionary of ranks writecsvdata 20 Properly opens the file to write Uses the correct filename Properly writes the data in the correct format Closes the file before exiting function 2 employeeranker Properly makes all the required function calls Does not let the program crash Returns True or False correctly in the appropriate situations 2