首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
COMP1011编程设计讲解、辅导JavaScript程序语言、Python编程讲解 讲解R语言编程|辅导留学生Prolog
项目预算:
开发周期:
发布时间:
要求地区:
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 1 of 11
In this coursework you will be writing Python functions as well as some JavaScript code to
perform various computations.
To create these functions you will use Spyder (or some other program editing software if you
prefer) to edit the template files given. The template files contain the names of the functions
you need to define. Do not change the name of the files or the names of functions in the file,
otherwise it will cause difficulty for marking your code and you will lose marks. However, you
can add more functions/import if needed. On top of correct program output, you are also
marked for coding style. Make sure you have ticked the Enable code style linting option on
Spyder for conformance to the PEP 8 convention. Your answer file should be submitted via
Minerva in a single zip file.
(a) – Reading data from CSV file and displaying it in HTML [7 Marks]
(b) – Reading data from CSV and displaying structured information [14 Marks]
(c) – Retrieve data from the web [9 Marks]
(d) – JavaScript [10 Marks] (Not required for COMP0011 (IFY) students)
The total mark for this coursework is 40 marks for COMP1011 students. For COMP0011
(IFY) students, who do not need to attempt part (d), the total mark is 30 marks. Of the total
mark, 6 marks are allocated for coding style conformance to PEP 8. The weighting of this
mark in relation your overall module grade will depend on the particular module you are
taking. Full details are on Minerva.
Questions
(a) Reading data from CSV file and displaying it in HTML [7 Marks]
Write a function create_html_display_data(title, csvfile, htmlfile) that
read a given CSV file (csvfile) and display the data in a table in an HTML file (htmlfile).
The title is for the title and the heading
of the html page. If the file is not found, print
“csv file not found”. Assume that the user always enter a valid CSV formatted file.
You are provided with the following files to help you with this task:
Starting template file for your code:
display_data_html.py
A useful example file that creates an HTML file that displays data in a table:
create_html_table.py
A CSV file containing food hygiene website traffic data, on which to test your function:
o web-traffic-2018.csv
You are free to add other functions/import to be used by your code. For example, you may
refer and adapt the code from the function create_html_table_with_data(data) in
create_html_table.py. You may also refer to the module reading material "Writing
HTML using Python" for another example of creating a HTML file and reading data from a
CSV file.
The output for a basic solution when the function is tested with “web-trafffic-2018.csv” with
title “Food Hygiene Rating Website Traffic Data 2018” should look something like this:
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 2 of 11
You can pass this coursework with a basic solution but you can gain higher marks if you add
further decorations, more sophisticated formatting to your output. For example, you could get
your output to look something like the figure below with alternating background colour for
each row. In this example, the following list of colours is used.
HTML_COLORS = ['Green', 'Silver', 'Lime', 'Gray', 'Olive', 'White', 'Red', 'Blue', 'Purple', 'Teal',
'Fuchsia', 'Aqua']
You can also produce a more advanced version to look something like the figure below with
different background colour for different month of the year and centre justified text. In this
example, the following list of colours is used.
HTML_COLORS = ['Green', 'Silver', 'Lime', 'Gray', 'Olive', 'White', 'Red', 'Blue', 'Purple', 'Teal',
'Fuchsia', 'Aqua']
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 3 of 11
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 4 of 11
(b) Reading data from CSV and display structured information [14 marks]
Similar to part(a) in this coursework, write a function summarised_data_html(title,
csvfile, htmlfile) to read the data from a given CSV file and displaying data in a
HTML table; but this time you will need to process the data before displaying the
summarised information. If the file is not found, print “csv file not found”. Again, assume that
the user always enter a valid CSV formatted file.
You are provided with the following files to help you with this task:
Starting template file for your code:
summarised_data_html.py
A useful example file that creates an HTML file that displays summarised data in a
table:
process_summary_html.py
A CSV file containing food hygiene website traffic data, on which to test your function
(same as for (a)):
o web-traffic-2018.csv
You are free to add other functions/import to be used by your code. For example, you may
refer and adapt the code from the functions in example file process_summary_html.py.
You need to modify and extend summarised_data_html(title, csvfile,
htmlfile) so that the function creates a HTML file displaying the average value for each
month in the given CSV files. For example, the table below is the data for the month of
January 2018 in the file “web-traffic-2018.csv”.
Date Visits UniqueVisitors Pageviews
01/01/2018 10620 9575 45765
02/01/2018 8912 8061 42513
03/01/2018 9073 8074 42334
04/01/2018 9225 8290 46141
05/01/2018 14470 13253 74009
06/01/2018 14082 12765 66577
07/01/2018 9546 8724 43839
08/01/2018 11048 9991 45218
09/01/2018 8998 8043 42235
10/01/2018 9574 8630 43817
11/01/2018 8963 7858 43594
12/01/2018 10996 9795 53147
13/01/2018 10942 9923 48806
14/01/2018 8512 7773 39729
15/01/2018 7996 7008 41490
16/01/2018 9442 8370 45487
17/01/2018 8323 7412 40152
18/01/2018 8326 7431 40744
19/01/2018 10733 9530 51035
20/01/2018 11493 10359 52138
21/01/2018 10333 9446 49331
22/01/2018 10734 9640 52800
23/01/2018 9804 8813 49617
24/01/2018 9476 8363 49916
25/01/2018 9724 8651 48253
26/01/2018 12024 10816 57542
27/01/2018 12703 11467 60628
28/01/2018 11859 10671 54237
29/01/2018 18045 16283 96096
30/01/2018 14406 12880 70320
31/01/2018 11095 9821 51028
The sum value for the field Visits is 331477, UniqueVisitors is 297716, and Pageviews is
1588538. Therefore, the mean (average) value for the field Visits is (331477/31) =
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 5 of 11
10692.80645, UniqueVisitors is (297716/31) = 9603.741935, and Pageviews is (1588538/31)
= 51243.16129.
The output for a basic solution when the function is tested with “web-trafffic-2018.csv” with
title “2018 Food Hygiene Ratings Website Traffic (Mean)” should look something like this:
You can pass this coursework with a basic solution but you can gain higher marks if you add
further decorations, more sophisticated formatting to your output.
For example, you could get your output to look something like the figure below with
alternating background colour for each row.
You can also produce a more advanced version to look something like the figure below with
the highest mean value in bold (Nov 2018 for Visists, Nov 2018 for UniqueVisitors, and Nov
2018 for Pageviews) or in other formatting.
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 6 of 11
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 7 of 11
(c) Retrieve data from the Web [9 Marks]
For this question, you will retrieve data in CSV format from the web. Data stored on web
pages can be accessed in Python using the urllib module.
The New Zealand Government publishes online datasets on population, business, labour
market, society, economy, and environment. These datasets are licensed under the Creative
Common Attribution 4.0 International licence. For this question, you are going to use the
marine economy data from 2007 to 2018 from the URL:
https://www.stats.govt.nz/assets/Uploads/Environmental-economic-accounts/Environmentaleconomic-accounts-2020-tables/Download-data/marine-economy-2007-18.csv
You need to write code in the following functions in the given template file “query_web.py”:
1. display_detail_data(data) [5 Marks]
This function will take the marine economy data as its argument and display the details. A
sample function to retrieve data from the web called get_csv_data_from_url(url)
is provided in the template file query_web.py. You can use this function to retrieve the
data from the url and supply it to your function display_detail_data(data). Note
that the first row of the data returned by get_csv_data_from_url(url) is the header
of the columns.
For basic solution, you can simply loop over the data and display it as shown in figure below.
However, you can gain higher marks if you can format our output as shown below by
hardcoding the headers for each column.
You can also produce a more advanced version with column headers extracted from the first
row of the data. In this case, other online datasets such as renewable energy stock account
from 2007 to 2018 at
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 8 of 11
https://www.stats.govt.nz/assets/Uploads/Environmental-economic-accounts/Environmentaleconomic-accounts-2020-tables/Download-data/renewable-energy-stock-account-2007-
18.csv can also be displayed correctly.
2. display_GDP_data_year(data, year) [4 Marks]
The marine economy data contains the column headers: year, category, variable, units,
magnitude, source, data_value, and flag. This function will take 2 arguments: the retrieved
marine economy data, and the year. The function will return the value from data_value for
„GDP‟ in the column variable and the specified year. You can use the same
get_csv_data_from_url(url) function to retrieve the data from the url and pass it to
your function display_GDP_data_year(data, year). Assume the user always
enter valid data and year. If data for the year is not found, return “data not found”.
The marine economy data from 2007 to 2018 is assessable at the URL:
https://www.stats.govt.nz/assets/Uploads/Environmental-economic-accounts/Environmentaleconomic-accounts-2020-tables/Download-data/marine-economy-2007-18.csv
Example
year output
2008 564630
2012 839196
2018 1133460
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 9 of 11
(d) JavaScript [10 Marks]
For this question you will add code to a given file HTML (bill_sharing.html) and modify
the JavaScript function for bill sharing. The template file contains HTML and JavaScript code
to display input boxes, selection box, and text to display calculated amount to be paid by
each person as shown in figure below.
1. Add
heading [1 Mark]
Add code to the bill_sharing.html to display a
heading “Bill Sharing Calculator”
similar to figure below.
2. Add validations to function [6 Marks]
Modify the billSharing() function to include validations for input for bill amount, tips
amount, and the number of people to share the bill. If invalid data is entered, the following
alert() messages should appear.
Pressing the Calculate! button with invalid bill amount such as “” (empty) or non-numeric
value such „q‟ gives the following message. You can use JavaScript isNaN() function to
check whether a value is not a number.
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 10 of 11
Pressing the Calculate! button without selecting the tips amount gives the following message.
Pressing the Calculate! button with invalid number of people to share the bill such as “”
(empty) or non-numeric value such „q‟ gives the following message. You can use JavaScript
isNaN() function to check whether a value is not a number.
3. Add bill sharing calculation codes [3 Marks]
Further modify the billSharing() function to calculate the amount to be share between
the people involved. For example, if the user entered 100 for the bill amount, selected 20% -
Good, and 2 people to share, the page will display “Each person to pay £60.00” similar to the
figure shown. You can use toFixed() method tor round a number to specified number of
decimals. For example, vNum.toFixed(2) will convert the vNum to two decimal points.
COMP1011 COURSEWORK 3: HTML with Python and JavaScript
Page 11 of 11
Submission Instructions
You should submit via the submission widget on the Assessment page of the module's
Minerva pages. Your submission should be in the form of a zip file cw3.zip containing all files
for all questions. You can submit multiple times, only the last submission will be marked. You
submission will be marked after the submission deadline.
The deadline for submissions is 10 am on Thursday 10 December. The standard university
penalty of 5% of available marks per day will apply to late work.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
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
软件定制开发网!