代写Python基础作业,分为三个模块,包括基本数学问答,HTML生成器以及Web的数据分析器。
Overview
This resit coursework incorporates all the main aspects of Python and web-
based programming that were covered in the COMP1011 module:
- Part 1 (worth 30 marks) involves basic Python programming and is not specifically web-related and requires skills similar to those used in Courswork 1 of the module.
- Part 2 (worth 10 marks) concerns using Python to extract information from a CSV file and display it, firstly in simple text output to the console, and then as an HTML web page. This requires skills similar to those that were tested in Coursework 2 of the module.
- Part 3 (worth 10 marks) is about retrieving data from an online repository and finding and displaying specific information from that data. This is also related to the coding that was required for Coursework 2 of the module.
It is suggested that as well as using the general material on the module
website at students also look at the specifications for the original
courseworks (under the ‘Coursework’ tab on that website), which contain
various relevant tips and suggestions.
Submission
Your files must be submitted as a Zip archive. No other format will be
accepted. Your solution should be submitted via the Blackboard VLE before the
deadline. All submissions will be submitted to plagiarism detection software.
The files you should submit are the following:
- maths quiz.py
- display playlist.py
- earthquakes.py
Part 1 Mathematical Quiz Program
For this part of the coursework you should write a console-based arithmetic
quiz program. Your code should be in a file called maths quiz.py. The program
should output a sequence of simple mathematical questions concerning addition,
subtraction, multiplication, division, and possibly other kinds of arithmetic
calculation. For example, one of the questions could be:
What is the value of 4 + 7 ?
After outputting each question, your program should prompt the user to enter
an answer. You should restrict your quiz to questions and answers involving
only whole numbers (some of which might be negative). However, within this
limitation, a variety of different kinds of questions may be asked.
To obtain higher marks, you will need to produce a program that does not
always give the same quiz but generates different questions randomly each time
it is run. Marks will be awarded depending on the length, complexity,
diversity and other features of you program, according to the following mark
scheme:
- (a) Appropriate, informative and concise text is displayed explaining the purpose of the program, prior to starting the actual quiz.
- (b) At least one question is asked.
- (c) Five or more questions asked.
- (d) Ten or more questions asked.
- (e) A variety of different types of questions are asked. The types of question can be: addition, subtraction, multiplication, division, calculating the square or square root of a number etc.
- (f) The program keeps a total of the number of questions correctly answered and outputs this, along with suitable text, at the end of the quiz.
- (g) The program checks that all answers input by the user are whole numbers. If not the program does not crash but tells the user that they must enter a whole number (possibly negative) and asks the question again.
- (h) The program generates a new random quiz each time. You should import the random module which provides a function that returns a random integer in a given range. You should use this both to select the type of each question and also the particular numbers that the question asks about. (You will need to import the random module to do tackle this part of the question.)
- (i) The program allows multiple quizzes to be run. After each quiz is completed the user is prompted regarding whether they wish to do another quiz or quit.
- (j) After taking a quiz, as well has having the options of doing another quiz or quitting, the user has the further option of redoing the same quiz as they have just done. (You can only obtain marks for this if your program generates random quizzes, as specified in part (h)).
- (k) The program includes suitable informative comments, including a brief description of what has been implemented at the top of the program file.
Part 2 Generating HTML from a CSV Data File
Your goal for this part of the coursework is to write a Python program that
can read information about music tracks from a CSV file (i.e. a file in Comma
Separated Value format) and output the information in an easily readable
format. For the first part of this question you will display the information
in a plain text format and for the second part you will generate an HTML file
that can be viewed in a browser.
- (a) Write a Python program in a file called display playlist.py that includes a function display playlist(filename) that will read information from the example file geek-music.txt, or any file formatted in a similar way, and produce a list of track information that is output to the console in the format shown below.
- (b) Add to your program display playlist.py a function make html playlist(filename) which (as for part (a)) reads in information from a CSV file in the format of geek-music.txt and creates an HTML file, which, when viewed in a browser, displays the information content of the original file in a clear and visually pleasing way. The web page should have a heading which says which playlist it was generated from. You should use an HTML
<table>
element to lay out the information. The table should have a border and you should set the table background colour. You should use different fonts for each of the columns of the table.
Part 3 Accessing and processing information from the Web
For this part of the coursework, you should start with the file
earthquakes.py, which you can download from the VLE. This contains functions
to extract earthquake data, either from a file (function readDataFromFile) or
from the online data provided by the US Geographical Society (USGS) (function
readDatafromURL). To answer this question, add code to that file and submit
your extended version of earthquakes.py.
- (a) Wite a function offlineDisplayLargestQuake() that will extract data from the earthquakedata.csv file, find the largest magnitude quake and display information about that quake. (Hint: Your code will be easier to construct if you first write: a function to display information for any quake record in the list of earthquake data, a function to find the quake record with the highest magnitude in the list.)
- (b) Wite a function onlineDisplayLargestQuake() that will extract data from the online USGS earthquake data resource and display it in similar fashion to the previous part.
- (c) Write a third function displayLargestQuake() that will first try to download the online
USGS data but if this fails will use the local earthquakedata.csv file. In
either case it should display the largest magnitude quake, as for the previous
functions. The output should also inform the user whether the online or local
data is being used.