python代写-MSCI530/MSCI537
时间:2021-01-04
Lancaster University, Department of Management Science
MSCI530/MSCI537: Data Sourcing, Handling and Programming
Coursework (70% for MSCI530 and 100% for MSCI537)
Deadline: 12/1/2021 10AM Michaelmas Term Maximum Marks: 100
1 Coursework Description
This coursework is composed of three parts, and you are expected to submit six files. You have
been given the flexibility to structure the code in the way that you think is best following the
principles of re-usability, maintainability, information hiding and clarity.
Part 1 (20 Marks)
For this part, you should submit a file containing a working version of your code. The name of
this file should be part1.ipynb (programmed in Python with Jupyter Notebook as an Editor).
You should also submit a document file named part1.docx containing a copy of your code. You
should not import any modules/packages for this part.
Fiz-Buz is a mathematical game, often encouraged by school teachers. In this game the players
take turns to count through numbers (1, 2, 3 etc). If a number either contains a 5, or if it is
divisible by 5 then a player must say “Fiz” instead of that number. If it either contains a 7, or is
divisible by 7, then they must say “Buz” instead of that number. If a number meets both “Fiz”
and “Buz” criteria, then they must say “Fizbuz”.
Task 1: (12 marks) Write a Fiz-Buz simulator that will calculate whether a number should be
represented by itself, “Fiz”, “Buz” or “Fizbuz”. The simulator should perform this calculation for
numbers between 1 and n2, where n is a user input, and the results should be displayed in a n×n
table. This table should contain a heading containing the title of the program and your name (in
the centre), and it should be surrounded by a box made up of ‘-’ and ‘|’ characters. The output of
the program should thus be as shown below for n = 10.
The programs should run without errors and meet the above specification (i.e. by correctly
identifying Fiz and Buz numbers, and formatting the output correctly as required above).
Please Turn Over
MSCI530/MSCI537 Data Sourcing, Handling and Programming Page 2 of 4
Task 2: (8 marks) These marks will go to programs that are (i) well commented, and have a
good style (neatly laid out, with sensible identifiers); and (ii) well structured (for example, by
following good programming practices and using functions where appropriate) to show evidence of
well thought out design. Additionally, the quality of the code will be considered (i.e. some marks
will be given for compact efficient algorithms, and compact code).
Part 2 (40 Marks)
For this part, you should submit a file containing a working version of your code. The name
of this file should be part2.py (programmed in Python with Spyder as an Editor). You should
also submit a document file named part2.docx containing your answer to the question below (6
pages maximum) and your code (as an appendix - no page limit). In case you want to import any
packages apart from pandas, matplotlib, numpy, math, random, tkinter, pickle, seaborn and norm
from scipy.stats, you should contact the module leader first.
A newly appointed health minister has heard reports that there are some hospitals in England
where the average length of stay of patients is over 2 weeks, whereas in many others the average
length of stay is under 1 week. This sounds rather odd at face value, but he realises that he does
not understand much about the activity levels of hospitals, and would like to improve his level of
understanding. Suppose that the data file ‘Hospital.csv’ contains the following data for the 303
NHS hospitals in England:
• Hospital – Code identifying hospital
• ALLPatients – Patients admitted in last year
• Males – Male patients admitted in last year
• Females – Female patients admitted in last year
• Emergencies – Emergency patients admitted in last year
• LOS – average length of stay of patients in last year
• Age – average age of patients admitted last year
• LOS PY – average length of stay of patients in previous year
• Age PY – average age of patients admitted previous year
Draw a sample of size 100 from this population and investigate your sample using Python. As at
the lecture, use random state to set your unique starting point for the random number generator.
For this coursework question use the last four digits of your library card PLUS 1, i.e. if your
library card ends ‘4321’ type in ‘4322’, and if your library card ends ‘4329’ type in ‘4330’. Record
these four digits at the top of your answer.
Task 1: (10 marks) In no more than 6 pages describe the main features of your sample as if
to a non-statistical health minister. You should include main features of individual variables and
of the relationships between them. You must include Python numerical and graphical output.
(The clarity and content of your report are both important - grades will be awarded on quality of
technical analysis. Your report should not be a discussion of how you used Python to perform the
calculations. You also need to think carefully about which output is relevant to use in the report).
Task 2: (30 marks) These marks will go to programs that are well structured (including employing
functional and object oriented programming concepts), well commented, intuitive to use (i.e.
Please Turn Over
MSCI530/MSCI537 Data Sourcing, Handling and Programming Page 3 of 4
straightforward for me to run your code), generalisable, and flexible (i.e. provide user options
via a graphical user interface). The program should run without errors and produces the same
output used in your report.
Part 3 (40 Marks)
For this part, you should submit a file containing a working version of your code. The name of
this file should be part3.py (programmed in Python with Spyder as an Editor). You should also
submit a document file named part3.docx containing a copy of your code. In case you want to
import any packages apart from pandas, matplotlib, numpy, math, random, tkinter, pickle, seaborn
and norm from scipy.stats, you should contact the module leader first.
Alex owns an auto repair business and has several employees. In this part, you are to write a
program for Alex that stores/deletes/updates data about employees, calculates and displays the
gross pay and more. The tasks below are designed to help you to develop your program in stages.
Task 1: (2 marks) Write a class named Employee that holds the following data about an employee
in attributes: name (e.g. “Ahmed Kheiri”), ID (e.g. “E182737”), department (e.g. “IT”), job title
(e.g. “Programmer”), hourly pay rate and number of hours worked in a week.
Task 2: (2 marks) Law requires that hourly employees be paid “time-and-a-half” their regular
hourly pay rate for work in excess of 40 hours in a week. Therefore, if the employee has worked
over 40 hours in a week, he or she gets paid extra for all the hours over 40. Otherwise, the overtime
calculation should be skipped. To give an example, if a person’s hourly wage is £12 and he or
she works 60 hours in a week, the person’s gross pay should be £840. Implement a method that
calculates and returns an employee’s gross pay, including any overtime wages.
Task 3: (2 marks) Alex’s company has a reputation for providing excellent fringe benefits. One
of their benefits is a retirement plan for each employee. The company contributes 5 percent of each
employee’s gross pay to their retirement plans. Implement a method that calculates and returns
the company’s contribution to an employee’s retirement account for a week.
Task 4: (2 marks) Now, write a class named ProductionWorker that is a subclass of the Employee
class. This class has an attribute ‘shift’ (a boolean data type). The workday is divided into two
shifts: day shift and night shift. The shift attribute will hold a boolean value representing the shift
that the employee works.
Task 5: (2 marks) Now that you have written the classes, write a code that creates objects of the
two classes and prompts the user to enter data for each of the object’s data attributes, and stores
the data in the objects. Implement the str method for a string representation of the objects.
Task 6: (12 marks) Update your program so that it stores Employee and ProductionWorker
objects in a dictionary. Use the ‘ID’ as the key. The program should present a menu that lets the
user perform the following actions:
• Look up an employee in the dictionary. Suppose each employee has a unique ID, we could
look up and retrieve an employee’s name, department, etc, by entering that employee’s ID
• Search for records, for example, enter a department and display a list of all the employees
and production workers matching that department
Please Turn Over
MSCI530/MSCI537 Data Sourcing, Handling and Programming Page 4 of 4
• Add a new employee to the dictionary (i.e. the new object will be added to the dictionary’s
existing contents)
• Change an existing employee’s name, department, . . . etc. This will allow us to keep the
records up to date
• Delete an employee from the dictionary
• Display all the objects in the dictionary in a suitable table format
• Quit the program
When the program ends, it should pickle the dictionary and save it to a file. Each time the
program starts, it should try to load the pickled dictionary from the file. If the file does not exist,
the program should start with an empty dictionary.
Task 7: (2 marks) Write a function that stores the data about employees and production workers
in a text file named “employee.txt”. The file should contain a record for each employee and
production worker from the created dictionary. Each record will be a collection of the following
fields: ID, name, department, job title, gross pay and shift (i.e. day or night - only applied to
production workers).
Task 8: (12 marks) Design a suitable graphical user interface, and produce suitable plots (e.g.
pie chart showing the distribution of departments).
Task 9: (4 marks) These marks will go to programs that are well structured (using functional
programming concepts and follow good programming practices), well commented and intuitive to
use (i.e. straightforward for me to run your code).
2 Coursework Submission
The coursework deadline is 10:00AM, Tuesday 12th January, 2021. In accordance with University
regulations, work submitted up to three days after the deadline will be classed as late submission
(10 marks will be deducted), and after three days as a non-submission. However, if an extension
is given then the rule applies from the date of the extension. The place to submit your files:
• https://modules.lancaster.ac.uk/mod/assign/view.php?id=1435010 for MSCI530
• https://modules.lancaster.ac.uk/mod/assign/view.php?id=1436880 for MSCI537
3 Plagiarism
You must write your own code. Copying code from other students, previous students or any other
source is plagiarism. According to university rules, instances of plagiarism will be treated very
seriously. Penalties are in line with the institutional framework of the University. We will analyse
the coursework using plagiarism detection software. Your coursework will be checked against that
of the rest of the class, and against that of previous students. In the days following submission, and
at a prearranged time, selected students will be asked to spend a few minutes on Teams where you
will demonstrate your program to me. I will use this opportunity to ask you to provide information
on your program and explain parts of your code.



















































































































































essay、essay代写