Last active
December 29, 2018 18:31
-
-
Save ryanorsinger/4ce15aa78e33c25b2bf59ed5fa4b6e81 to your computer and use it in GitHub Desktop.
Sales report challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assign the following string to a variable named sales_string. "Monthly Sales Report\nDate: 03-17-2015\nOffice: Codeup\n ===================================================\nEmployee Number, First Name, Last Name, Sales Units\n***************************************************\n\n1, Jane, Janeway, 3\n3, Tricia, Triciason, 5\n4, Jeannette, Jeanson, 4\n5, Charles Emmerson III, Winchester, 2\n6, Chet, Chedderson, 8\n7, Chaiam, Chaiamson, 12\n8, Dale, Dalesinger, 1\n9, Zig, Ziglar, 50\n10, Henry, Kissinger, 1\n11, Arthur Herbert, Fonzarelli, 23\n12, Betty, Boop, 67". Now, write a function named sales_report() that takes in the sales_string as an argument. | |
# Now write a function named sales_report() that takes in this string as its input. | |
# The sales_report will be returning a dictionary with the following keys | |
# number_of_employees is a key that returns a value containing the number of employees | |
# total_units_sold is a sum of all units sold by this sales team | |
# average units sold per employee is the total units sold divided by number of employees. | |
# most_units is a key that points to the name of the highest performing salesperson | |
# least_units is a key that points to the name of the lowest performing salesperson | |
sales_string = "Monthly Sales Report\nDate: 03-17-2015\nOffice: Home Office\n ===================================================\nEmployee Number, First Name, Last Name, Sales Units\n***************************************************\n\n1, Jane, Janeway, 3\n3, Tricia, Triciason, 5\n4, Jeannette, Jeanson, 4\n5, Charles Emmerson III, Winchester, 2\n6, Chet, Chedderson, 8\n7, Chaiam, Chaiamson, 12\n8, Dale, Dalesinger, 1\n9, Zig, Ziglar, 50\n10, Henry, Kissinger, 1\n11, Arthur Herbert, Fonzarelli, 23\n12, Betty, Boop, 67" | |
# Hint: this input is a CSV format, like a spreadsheet! | |
# Since a CSV is two dimensional data, recommend splitting the original string to produce a list of strings. | |
# To identify the "delimeter", focus on which character separates each "row" of data. | |
# Some rows contain only formatting characters. Ignore or delete these rows. | |
# This list of strings contains the rows of data where each row is a full string containing all values. | |
# The first string of the list of strings should be "Monthly Sales Report". The next should be the Date, etc... | |
# Consider that each "row" may need to be split by another delimeter to access each field. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment