lab9.py - CS 177 lab9a.py L05 Team 1 Lindsey Kumfer...

This preview shows page 1 - 2 out of 4 pages.

# # CS 177 - lab9a.py, L05 Team 1 # Lindsey Kumfer, 0027660682 # Following Coding Standards and Guidelines # This program reads a file of employee names, departments, and hours, and then # displays a total of the wages the employee earned during Jan-Mar. # # Import graphics library from graphics import * # Define main() function def main(): hours = "employeeHours.txt" # Call data function employees = data(hours) # Call process function DictEmp = process(employees) # Call menu function menu(DictEmp) # Define data() function def data(hours): # Open and read the file file = open(hours, "r") # Read lines into a list file_read = file.readlines() # Split into list of lists employees = [] for line in file_read: i = line.strip("\n").split(", ") employees.append(i) # Make hours worked a float for line in employees: line[3] = float(line[3]) file.close() # Return return employees # Define process() function def process(employees): # Empty dictionary DictEmp = {} # Total payroll calculation for line in employees: # Employee ID as dictionary key name = line[1] if name not in DictEmp: DictEmp[name] = [0.0, 0.0, 0.0] # Find out the month if "M" in line[0]: month = 2 if "F" in line[0]: month = 1 if "J" in line[0]: month = 0 # Determine department if line[2] == "TECH": rate = 9.50 if line[2] == "SHIP": rate = 8.75 if line[2] == "ADMIN": rate = 9.25 if line[2] == "SALES": rate = 9.00

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture