Overview • You are required to carry out some data processing in Python) on the data set provided and to present your submission as a single runnable Python file. • The data set contained in the CSV...

1 answer below »
Overview
• You are required to carry out some data processing in Python) on the data set provided and to present your submission as a single runnable Python file.
• The data set contained in the CSV file ProjectData.csv contains details of thousands of orders including Order Quantity, Sales Value, Profit, Province, Shipping Mode and Shipping Cost. The Money figures are in Euros.
Specification
• When a total is requested for any category it should include Total order quantity, Total sales, Total Profit and Total shipping cost.
• Any output to the console should be understandable to someone without any prior knowledge of the program. Your Python code should only use standard Python modules and no additional packages like pandas.
• No output figures should be hardcoded, they should all be calculated by the program.
i. In your main method load the data set into a python dictionary. This dictionary can be passed to all your functions.
ii. Create a function, show_province_totals(), which accepts a province and outputs the totals for that province.
iii. Create a function, show_shipping_totals() which accepts a shipping mode and outputs the totals for that shopping mode.
iv. Create a function, total_orders_under(), which accepts a Euro amount and outputs the total order quantity under that number.
v. Create a function, show_orders_given_quantity_range(), which accepts an order quantity and outputs each record having that order quantity, one per line.
vi. Your main method should output for all the provinces and shipping methods in (ii) and (iii).
vii. Your main method should output total_orders_under(50), total_orders_under(100) and total_orders_under(1000).
viii. Your main method should output show_orders_given_quantity_range(30) and show_orders_given_quantity_range(40).
1. The following tuples may be useful but are not required:
provinces = ('Munster', 'Leinster', 'Connacht', 'Ulster')
ship_mode = ('Delivery Truck', 'Express Air', 'Regular Air')
2. Loading the CSV file in excel or using the Variable explorer debugger may help you.
3. Another option is to test with a smaller dataset initially, e.g. make a copy of the CSV file with a smaller subset of rows, say 20.
Conventions (summarised from Pep8)
• Coding
o Use 4 spaces as the indentation width, no tabs is the Pythion standard and the default in IDLE settings
o Put every statement on a line by itself
o Use blank lines to separate function definitions
o It is ok to use an occasional blank line between functions to separate sections (but consider making them separate functions)
o All import statements should be at the top of the file, each import should be on a separate line
o Use well named variables that indicate what the purpose of the variable
o Ideally comments should be complete sentences and use proper English.
• Naming
o use underscore notation or camel case notation
o Function and method names should be verbs; class and variable names should be nouns.
o Don't leave out letters or otherwise abbreviate names (common abbreviations like max are okay).
Answered Same DayMar 29, 2021

Answer To: Overview • You are required to carry out some data processing in Python) on the data set provided...

Pritam answered on Mar 30 2021
160 Votes
# import modules
import csv
import math

# set name of CSV file containing data
filename = "ProjectData
.csv"

# declaring tuples
provinces = ('Munster', 'Leinster', 'Connacht', 'Ulster')
ship_mode = ('Delivery Truck', 'Express Air', 'Regular Air')
# initializing data dictionary
orders = {}
# implementation of show_province_totals() function
def show_province_totals(provinceName):
totalQty = 0
totalSales = totalProfit = totalShipCost = 0.0
for orderId in orders:
if orders[orderId][5] == provinceName:
totalQty += orders[orderId][0]
totalSales += orders[orderId][1]
totalProfit += orders[orderId][3]
totalShipCost += orders[orderId][4]
result = (totalQty, totalSales, totalProfit, totalShipCost)
return result
# implementation of show_shipping_totals() function
def show_shipping_totals(shipMode):
totalQty = 0
totalSales = totalProfit = totalShipCost = 0.0
for orderId in orders:
if orders[orderId][2] == shipMode:
totalQty += orders[orderId][0]
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here