CS计算机代考程序代写 algorithm Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…

Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
!
A new course announcement has been posted. Click here to view the new announcement.
Module 8: Searching and Sorting
Course ” Algorithms ” Assignment8 ” SalesReport
Sales Report
You are working on sorting data for a sales report in a grocery store. You are provided with a list of Transactions (sales for that day – see the code block below for a data de”nition).
1. Write a function
that consumes an unsorted list of distinct Transactions, and returns a new sorted list.
The output list contains the same data as the input list, but the data should be sorted by date, oldest
to newest, and then by amount, from lowest to highest. The sample below illustrates this sorting order. Sample:
sales_report(transactions)
1 of 7 3/30/21, 12:17 AM

Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
2. Write a second function
top_sales(sorted_transactions)
that consumes a non-empty sorted list as given by the output of sales_report on a list of Transactions. This function prints a report showing the top sale for each unique day that appears in sorted_transactions, ordered from oldest to newest transaction.
The report has the following structure:
Line 1: The title “Top Sales:”
Line 2: The date range of the report. The format for this line is:
L = [[’31-01-2021′, 9999928.22 , ‘Adam’],
[’02-02-2021′, 71.52, ‘Adam’],
[’01-02-2021′, 94400.45, ‘Oliver’],
[’02-02-2021′, 85.66, ‘Adam’],
[’31-01-2021′, 37334.66, ‘Celine’],
[’03-02-2021′, 77.2, ‘Frank’],
[’02-02-2021′, 31.12, ‘Celine’],
[’03-02-2021′, 44.37, ‘Celine’]]
sales_report(L) => [[’31-01-2021′, 37334.66, ‘Celine’],
[’31-01-2021′, 9999928.22, ‘Adam’],
[’01-02-2021′, 94400.45, ‘Oliver’],
[’02-02-2021′, 31.12, ‘Celine’],
[’02-02-2021′, 71.52, ‘Adam’],
[’02-02-2021′, 85.66, ‘Adam’],
[’03-02-2021′, 44.37, ‘Celine’],
[’03-02-2021′, 77.2, ‘Frank’]]
2 of 7 3/30/21, 12:17 AM

Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
MMM DD, YYYY – MMM DD, YYYY
where MMM is a 3-letter code for month, taken from the list below, DD and YYYY correspond to the 2-digit Day and 4-digit Year from the date “eld in the top Transaction for that day.
Line 3: Blank line
Lines 4+: One line for each unique day in the report, detailing the highest sale of that day. The format for this line is DD-MM-YY: $Amount SalesPerson. These “elds are separated by a space only. The date is the same format as in a Transaction. The Amount should be the top sale of that day, formatted with a leading dollar sign, and displayed to 2 decimals.
Month Codes:
1
January
Jan
2
February
Feb
3
March
Mar
4567
April
Apr
May
May
June
Jun
July
Jul
8
August
Aug
9
September
Sep
10
October
Oct
11
November
Nov
12
December
Dec
Sample:
3 of 7 3/30/21, 12:17 AM

Sales Report | Assignment 8 | CS 116 Courseware | UW Online
https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
L = [[’31-01-2021′, 37334.66, ‘Celine’],
[’31-01-2021′, 9999928.22, ‘Adam’],
[’01-02-2021′, 94400.45, ‘Oliver’],
[’02-02-2021′, 31.12, ‘Celine’],
[’02-02-2021′, 71.52, ‘Adam’],
[’02-02-2021′, 85.66, ‘Adam’],
[’03-02-2021′, 44.37, ‘Celine’],
[’03-02-2021′, 77.20, ‘Frank’]]
top_sales(L) => None
and the following is printed:
Top Sales:
Jan 31, 2021 – Feb 03, 2021
31-01-2021: $9999928.22 Adam
01-02-2021: $94400.45 Oliver
02-02-2021: $85.66 Adam
03-02-2021: $77.20 Frank
4 of 7
3/30/21, 12:17 AM
Loading last submission entry…
1 ##
2 ##
3 ##
4 ##
5 ##
6 ##
7 ##
8
A Transaction is a (list Str Float Str)
Requires:
First String is a valid date of the transaction
in the format DD-MM-YYYY
Middle Float is the amount of the transaction
to at most 2 decimal places
Last String represents the name of the sales person 9 def sales_report(transactions):

Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
Code Output
5 of 7 3/30/21, 12:17 AM

Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
Run Code Save Code
Reset Code
Show History Visualize Submit Code
Discussion
Topic: Module 8 / Sales Report
Show all posts
View Submissions
Hide Discussion
Add a Post
by recent activity
# method limitation enquiry
Are we allowed to use f-string? e.g. name = ‘Tushar’ age = 23 print(f”Hello, My name is {name} and I’m {age} year…
2
1
3
3
2
2 # displace to 2 decimals 2
?
Amount (Float) of a transaction
Can the amount have no decimal place (that is be an integer) though it is a Float?
# Part 2 title
In the example you give it seems that there is a space after the title of the sales report. But the requirement says…
# 2 decimal places
The Data De”nition said: “Middle Float is the amount of the transaction to at most 2 decimal places”, so 44.373 i…
# About transactions
For the function sales_report(transactions), can transactions be [] and [[]] ? Or it can only be [] ?
# build in sorting
Can we use build in sorting in this question?
6 of 7 3/30/21, 12:17 AM

Sales Report | Assignment 8 | CS 116 Courseware | UW Online https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/a2584c108…
# list of length 1 for top_sales
hi, if the list of transactions is of length 1, then how will the format be? will it be just the date or same day – same…
2 # Question 2
# Blank line after the “nal sale
Is it appropriate to have a blank line after the end of all the printed sales?
2 2
3 2
# The question 2 of Q3
It says we should display the answer to 2 decimals. I want to ask if the consumed list of this function has already…
# Does function 2 calls function 1 ?
So, I have 2 queries : 1. When I submit my assignment, does my second function have to call the “rst function to …
# part 2 Testing with check.set_screen
For part 2 example, i used check.set_screen. The test fails, but the actual output is exactly same as the expected …
7 of 7 3/30/21, 12:17 AM