首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
Data留学生编程辅导、讲解Python程序设计、Python编程讲解 讲解数据库SQL|讲解SPSS
项目预算:
开发周期:
发布时间:
要求地区:
PA10-B: Broadway Show Data File (20 pts)
Students:
This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns
about this content to your instructor. If you have any technical issues with the zyLab submission system,
use the Trouble with lab button at the bottom of the lab.
You have unveried
email(s). Please click on your name in the
top right corner and browse to your prole
to send another
verication
email.
14.32 PA10-B: Broadway Show Data File (20
pts)
Honor Code
THE ACADEMIC HONOR POLICY AS DISCUSSED IN CLASS AND POSTED
ON BRIGHTSPACE IS APPLICABLE TO ALL WORK YOU DO THIS FALL 2020
SEMESTER IN CS 1104.
Points and Submission
This exercise is worth 20 points. You have 10 submission attempts, so use them wisely and try
to pass all test cases before running out of submissions. Note also that you have to wait for at
least one minute before you can submit again.
Keep in mind that the score you get from zyLabs tells us how many test cases passed. The TA will
take this into account and then will manually look at your submission. They will look for any
possible deductions and incorrect style based on the grading rubric before entering your nal
score on codePost.
Problem Description
Write a program that will calculate and display statistics of Broadway shows where the data
comes from a comma-separated values (CSV) le.
We will use the reader function from the
csv module as seen in class that places the data from the CSV le
into a list that can then be
processed.
The CSV le
that will be used for this exercise is called boardway.csv and can be downloaded
below. The rst
line of the le
contains the names for each type of data stored in the subsequent
2020/11/20 14.32. PA10-B: Broadway Show Data File (20 pts)
https://learn.zybooks.com/zybook/VANDERBILTCS1104Fall2020/chapter/14/section/32 2/8
lines. Each of the remaining lines represents a week's worth of data for a specic
Broadway
show. The date range of the data is from 2010 to 2016. The CSV le
contains more than 10,000
lines, so it is a fairly large dataset. We will not be using all of the data available, but rather we will
be specically
interested in the following data items: month, year, name of show, attendance
totals, revenue totals, and performance totals.
For this exercise, the program should ask three things from the user: 1) what type of stats does
the user want to view, 2) the name of the show of interest, and 3) the year of interest. The type
of stats include attendance, revenue, and number of performances. Once this information is
obtained, the program should calculate the stats for the show and year of interest. This will
include stats that are separated by each month of the year and then at the end the sum of the
totals of each of the months. Once the stats has been printed, the program should terminate.
As seen in class, after the reader function in the csv module has been called and the result
stored in a variable, a loop can be used to iterate over the CSV object stored in that variable.
Also, as seen in class, in one iteration of the loop, the loop variable will contain a list representing
one of the lines of the CSV le,
where each element of the list represents the data that was
separated by commas. For example, consider the second line in the le:
"3","1/3/2010","1","2010","A Little Night Music","Walter
Kerr","Musical","7527","101","1031543","112","8"
The list that will be generated for this line will look something like the following. This represents
one line in the CSV le.
["3", "1/3/2010", "1", "2010", "A Little Night Music", "Walter
Kerr", "Musical", "7527", "101", "1031543", "112", "8"]
To access any element in the list, you can use regular numeric indices. The following are the
index values and data description in each line of the CSV le.
The ones that are bolded are of
interest in this exercise. Remember that each line represents one show's data for a particular
week.
Index Data
0 Day
1 Full date
2 Month
3 Year
4 Show name
5 Theater name
6 Show type
2020/11/20 14.32. PA10-B: Broadway Show Data File (20 pts)
https://learn.zybooks.com/zybook/VANDERBILTCS1104Fall2020/chapter/14/section/32 3/8
Index Data
7 Attendance
8 Percentage of capacity reached
9 Gross income (i.e., revenue)
10 Percentage potential of revenue
11 Number of performances
The example code below shows how to open the CSV le
and create the CSV object. It also uses
some of these indices listed above to access certain values. In this case, the code will print the
show names (index 4) associated to each line in broadway.csv le
that represent data for 2016
(index 3).
with open('broadway.csv') as file: # The CSV file name can be
hard-coded.
shows = csv.reader(file)
for show in shows:
# Code to skip the first line omitted.
if int(show[3]) == 2016:
print(show[4]) # Prints the show name of each line
of data.
Additional details:
You will need to search for shows that contain the text inputted by the user. That is, you
shouldn't search for an exact match. For example, as long as the show name contains
"lion king" (i.e., the text inputted by the user), include it in the stats calculation.
Note in the example code that the you will need to write the code to skip the rst
line,
because as previously stated, the rst
line contains the headers of each data element on
the subsequent lines. There are different ways to skip the rst
line, for example, you can
create a variable that you change the value of once you've reached the rst
line.
Another observation about example code: the value of show[3] had to be converted into
an integer. This is because every element of the list show will be of type string. You will
need to convert values to numeric values when needed.
As stated above, each line in the CSV le
represents weekly show data. However, you are
concerned with monthly totals. This will require adding up the data of the weeks in a
2020/11/20 14.32. PA10-B: Broadway Show Data File (20 pts)
https://learn.zybooks.com/zybook/VANDERBILTCS1104Fall2020/chapter/14/section/32 4/8
particular month.
As seen in the sample runs below, the rst
prompt to the user is to pick a stat type or zero
to quit. You can assume that the number that the user will enter will be an integer, but
make sure it is a number between zero and three. Continue prompting until such a value is
entered. If the user selects zero, then the program should terminate without doing any
processing.
You can expect that the user will enter a show name. Also, the year value that the user will
enter will be an integer. If no data was found for the show name and/or year inputted by
the user, the program should print No data found.
When you are developing your program, it might be better to work on a smaller sized CSV
le.
An additional CSV le
called boardway-small.csv is also available to download the
contains data for only the months of June, July, and August of 2016. This le
is provided if
you want to test using a smaller le.
None of the test cases below requires broadwaysmall.csv.
That is why in the example code above, the le
broadway.csv can be hardcoded
in your solution.
Make sure you are decomposing parts of the code that are can be used for multiple tasks
into functions. For example, the process of tabulating the totals for attendance, revenue,
and number of performances, can be done by one function. The only difference is which
element in the list will be observed. That information can be passed into the function via a
parameter. We will deduct points if your code contains redundant code that could have
been decomposed into a function. That is, if we see a section of code that is highly similar
to another section of code, then you may be deducted points for redundant code. Also, if
the user only wants attendance totals, don't calculate the totals of the other two (i.e., only
calculate the stats that the user wants).
In the printout, the text that is printed after the "Show:" word should be exactly what the
user inputted. This text should be printed in all uppercase letters. For example, if the user
inputted "lion king", then the text to be printed is LION KING,
One more important note: The object returned by the reader function will only be
available within the call of with. This means any code that uses the CSV object that is
generated must be within (i.e., indented) the call of with. When you decompose your
solution, make sure the function calls are within the call of with.
Sample run 1
Input:
1
lion king
2015
Run:
2020/11/20 14.32. PA10-B: Broadway Show Data File (20 pts)
https://learn.zybooks.com/zybook/VANDERBILTCS1104Fall2020/chapter/14/section/32 5/8
1 - Attendance stats
2 - Revenue stats
3 - Performance stats
Please select an option (0 to exit): 1
Enter show name: lion king
Enter year: 2015
Show: LION KING
Year: 2015
Stat: Attendance
----------------------
| Month | Total |
|-------|------------|
| 1 | 53198 |
| 2 | 52043 |
| 3 | 66667 |
| 4 | 55475 |
| 5 | 65104 |
| 6 | 54260 |
| 7 | 55829 |
| 8 | 68188 |
| 9 | 54277 |
| 10 | 54277 |
| 11 | 67035 |
| 12 | 53271 |
----------------------
TOTAL 699624
Sample run 2
Input:
2
aladdin
2014
Run:
1 - Attendance stats
2 - Revenue stats
3 - Performance stats
Please select an option (0 to exit): 2
Enter show name: aladdin
Enter year: 2014
2020/11/20 14.32. PA10-B: Broadway Show Data File (20 pts)
https://learn.zybooks.com/zybook/VANDERBILTCS1104Fall2020/chapter/14/section/32 6/8
Show: ALADDIN
Year: 2014
Stat: Revenue
----------------------
| Month | Total |
|-------|------------|
| 1 | 0 |
| 2 | 0 |
| 3 | 4453795 |
| 4 | 4767852 |
| 5 | 4693799 |
| 6 | 6644493 |
| 7 | 6071438 |
| 8 | 7690693 |
| 9 | 5181685 |
| 10 | 5754217 |
| 11 | 7152638 |
| 12 | 6639552 |
----------------------
TOTAL 59050162
Sample run 3
Input:
1
lion queen
2010
Run:
1 - Attendance stats
2 - Revenue stats
3 - Performance stats
Please select an option (0 to exit): 1
Enter show name: lion queen
Enter year: 2010
No data found.
Sample run 4
Input:
2020/11/20 14.32. PA10-B: Broadway Show Data File (20 pts)
https://learn.zybooks.com/zybook/VANDERBILTCS1104Fall2020/chapter/14/section/32 7/8
4
-1
0
Run:
1 - Attendance stats
2 - Revenue stats
3 - Performance stats
Please select an option (0 to exit): 4
Invalid option. Try again: -1
Invalid option. Try again: 0
Required program decomposition
For this exercise, the size of any function in terms of the number of lines used will be restricted.
One of the test cases will check that each function you implemented (including the main
function) contains at most 20 lines of code. This line limit includes the function denition
line.
Comment lines or empty lines don't count toward the line limit.
You are prohibited from using a semicolon (;) to place multiple statements in one line. The last
test case will check for this. The test case scans the entire source code looking for a semicolon.
To ensure that you are not agged
for using a semicolon, don't use a semicolon at all in the
code, including in any of the comments.
Notes
If you are working in PyCharm, make sure to download the CSV les
and place them in the
same folder where your Python le
is located.
All statements must be part of a function denition.
You must only use features of Python that have been described in class.
Style guidelines
Be sure you are following to the programming style guidelines as outlined in the CS 1104 Style
Guide document, which can be found on Brightspace under Content | Course Documents.
Courtesy of CORGIS
268376.1514804
LAB
ACTIVITY
14.32.1: PA10-B: Broadway Show Data File (20 pts) 0 / 14
Downloadable les
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!