COMP1011语言 写作、 辅导Java,Python编程设计

” COMP1011语言 写作、 辅导Java,Python编程设计COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 1 of 11In this coursework you will be writing Python functions as well as some JavaScript code toperform various computations.To create these functions you will use Spyder (or some other program editing software if youprefer) to edit the template files given. The template files contain the names of the functionsyou 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, youcan add more functions/import if needed. On top of correct program output, you are alsomarked for coding style. Make sure you have ticked the Enable code style linting option onSpyder for conformance to the PEP 8 convention. Your answer file should be submitted viaMinerva 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 totalmark, 6 marks are allocated for coding style conformance to PEP 8. The weighting of thismark in relation your overall module grade will depend on the particular module you aretaking. 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) thatread 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 H1 of the html page. If the file is not found, printcsv 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.csvYou are free to add other functions/import to be used by your code. For example, you mayrefer and adapt the code from the function create_html_table_with_data(data) increate_html_table.py. You may also refer to the module reading material WritingHTML using Python for Another example of creating a HTML file and reading data from aCSV file.The output for a basic solution when the function is tested with web-trafffic-2018.csv withtitle Food Hygiene Rating Website Traffic Data 2018 should look something like this:COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 2 of 11You can pass this coursework with a basic solution but you can gain higher marks if you addfurther decorations, more sophisticated formatting to your output. For example, you could getyour output to look something like the figure below with alternating background colour foreach 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 withdifferent background colour for different month of the year and centre justified text. In thisexample, 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 JavaScriptPage 3 of 11COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 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 aHTML table; but this time you will need to process the data before displaying thesummarised information. If the file is not found, print csv file not found. Again, assume thatthe 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 atable: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.csvYou are free to add other functions/import to be used by your code. For example, you mayrefer 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 eachmonth in the given CSV files. For example, the table below is the data for the month ofJanuary 2018 in the file web-traffic-2018.csv.Date Visits UniqueVisitors Pageviews01/01/2018 10620 9575 4576502/01/2018 8912 8061 4251303/01/2018 9073 8074 4233404/01/2018 9225 8290 4614105/01/2018 14470 13253 7400906/01/2018 14082 12765 6657707/01/2018 9546 8724 4383908/01/2018 11048 9991 4521809/01/2018 8998 8043 4223510/01/2018 9574 8630 4381711/01/2018 8963 7858 4359412/01/2018 10996 9795 5314713/01/2018 10942 9923 4880614/01/2018 8512 7773 3972915/01/2018 7996 7008 4149016/01/2018 9442 8370 4548717/01/2018 8323 7412 4015218/01/2018 8326 7431 4074419/01/2018 10733 9530 5103520/01/2018 11493 10359 5213821/01/2018 10333 9446 4933122/01/2018 10734 9640 5280023/01/2018 9804 8813 4961724/01/2018 9476 8363 4991625/01/2018 9724 8651 4825326/01/2018 12024 10816 5754227/01/2018 12703 11467 6062828/01/2018 11859 10671 5423729/01/2018 18045 16283 9609630/01/2018 14406 12880 7032031/01/2018 11095 9821 51028The sum value for the field Visits is 331477, UniqueVisitors is 297716, and Pageviews is1588538. Therefore, the mean (average) value for the field Visits is (331477/31) =COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 5 of 1110692.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 withtitle 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 addfurther decorations, more sophisticated formatting to your output.For example, you could get your output to look something like the figure below withalternating background colour for each row.You can also produce a more advanced version to look something like the figure below withthe highest mean value in bold (Nov 2018 for Visists, Nov 2018 for UniqueVisitors, and Nov2018 for Pageviews) or in other formatting.COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 6 of 11COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 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 webpages can be accessed in Python using the urllib module.The New Zealand Government publishes online datasets on population, business, labourmarket, society, economy, and environment. These datasets are licensed under the CreativeCommon Attribution 4.0 International licence. For this question, you are going to use themarine economy Data from 2007 to 2018 from the URL: httpss://www.stats.govt.nz/assets/Uploads/Environmental-economic-accounts/Environmentaleconomic-accounts-2020-tables/Download-data/marine-economy-2007-18.csvYou 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. Asample 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 thedata from the url and supply it to your function display_detail_data(data). Notethat the first row of the data returned by get_csv_data_from_url(url) is the headerof 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 byhardcoding the Headers for each column.You can also produce a more advanced version with column headers extracted from the firstrow of the data. In this case, other online datasets such as renewable energy stock accountfrom 2007 to 2018 atCOMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 8 of 11 httpss://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 retrievedmarine economy data, and the year. The Function will return the value from data_value forGDP in the column variable and the specified year. You can use the sameget_csv_data_from_url(url) function to retrieve the data from the url and pass it toyour function display_GDP_data_year(data, year). Assume the user alwaysenter 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: httpss://www.stats.govt.nz/assets/Uploads/Environmental-economic-accounts/Environmentaleconomic-accounts-2020-tables/Download-data/marine-economy-2007-18.csvExampleyear output2008 5646302012 8391962018 1133460COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 9 of 11(d) JavaScript [10 Marks]For this question you will add code to a given file HTML (bill_sharing.html) and modifythe JavaScript function for bill sharing. The template file contains HTML and JavaScript codeto display input boxes, selection box, and text to display calculated amount to be paid byeach person as shown in figure below.1. Add H1 heading [1 Mark]Add code to the bill_sharing.html to display a H1 heading Bill Sharing Calculatorsimilar to figure below.2. Add validations to function [6 Marks]Modify the billSharing() function to include validations for input for bill amount, tipsamount, and the number of people to share the bill. If invalid data is entered, the followingalert() messages should appear.Pressing the Calculate! button with invalid bill amount such as (empty) or non-numericvalue such q gives The following message. You can use JavaScript isNaN() function tocheck whether a value is not a number.COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 10 of 11Pressing 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 JavaScriptisNaN() 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 betweenthe 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 thefigure shown. You can use toFixed() method tor round a number to specified number ofdecimals. For example, vNum.toFixed(2) will convert the vNum to two decimal points.COMP1011 COURSEWORK 3: HTML with Python and JavaScriptPage 11 of 11Submission InstructionsYou should submit via the Submission widget on the Assessment page of the modulesMinerva pages. Your Submission should be in the form of a zip file cw3.zip containing all filesfor all questions. You can submit multiple times, only the last submission will be marked. Yousubmission will be Marked after the submission deadline.The deadline for submissions is 10 am on Thursday 10 December. The standard universitypenalty of 5% of available marks per day will apply to late work.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导