代做Writing Code and Code review Assignment 1代写Python语言
- 首页 >> Java编程Assignment 1
Writing Code and Code review
Due Dates:
Part I due on 27th March, 2025 Thursday, 11:55 pm - Week 5
Part II due Lab 1 of Week 6
Part III due Lab 2 of Week 6
Assessment Aim
This assessment assesses your ability to carry out core steps in programming that you have learned from week 1 through to week 5 in the course.
Learning Outcomes
The learning outcomes to be assessed in this assessment are:
● How to effectively use variables, conditionals and loops (LO1)
● Design, construct and test simple programs (LO2)
● Implement good programming practices (LO4).
By succeeding in this assignment, you will be in a position to implement most kinds of programming tasks encountered in future.
Task Overview
This is an open-book group assignment. The group size is 3 or 4.
There are three parts in this assessment.
Part One - Individual work: 10% (due at end of week 5, 2024)
This part of the assignment comprises four sections and each member is responsible for completing ONLY one section.
Each member is required to:
● write a set of functions that satisfy the given requirements
● review your code carefully
● submit your section to Moodle for marking.
To support you in reviewing your code, we provide a small example set of inputs and correct outputs. Please note that tests or example outputs never guarantee code correctness, so you need to check the correctness of your solutions.
Part Two - Peer code review: 5% (due at the end of Lab 1 of week 6, 2024)
Each member of the team is required to:
● review the code written by one other team member in a way so that everyone’s code is reviewed
● use the provided checklist to ensure the quality of your peer code review
● submit your code review to Moodle for marking
● keep a back-up copy of their work and share their individual work with their team members
In conducting peer code review, use the provided checklist. You can also use GenAI to find out what are the industry practices for peer code review.
Note: the industry practise might suggest about removing errors, for the sake of this assignment we would only like you to identify the problems and provide feedback to your team member.
Part Three - Combined Group work: 5% (due at the end of Lab 2 of week 6, 2024)
Each team member will:
● reflect on the peer review for their original code
● address any improvements that are required.
The whole team will:
● combine all the sections into one program (Python file)
● write one function together which will call all the functions implemented in Part One of the assignment.
The aim of this section is to enable students to work with the code developed by other team members and integrate their code successfully.
Guidance on the use of Generative AI
Generative AI tools CANNOT be used in Part One and Part Three of this assessment.
Generative AI tools are not restricted in Part Two of this assessment task. For example, you may use Chat GPT to search for information, brainstorm ideas, summarise information and/or explain it in simpler terms to help you with understanding.
Any use of generative AI must be appropriately acknowledged and you must put all your prompts and generative AI output in a separate section at the end of your code review.
Assessment Criteria
● Variables, Statements and Expressions
● Conditionals and Iteration
● Iteration and Sequences
● Dictionaries, Functions, Scoping and Namespaces
Submission Procedure for each Part
Your assignment will not be accepted unless it meets the requirements of the submission procedure:
Follow these steps to submit your full assignment.
Part I submission:
● Include a word file with title page providing these details: assessment details
(Assignment 1 Part 1) and student details (name and the student ID). If you have used any concept in your assignment that is not covered in the unit delivery. Then include the explanation of the concept with references.
● Save your file(s) into a zip file called AssignmentDetailsStudentID.zip (e.g. Assignment1Part1s123456.zip
● Submit your zip file containing your entire submission to Moodle.
● Note that your assignment will NOT be accepted unless you have completed all of the steps mentioned above.
Part 2 submission
● Include a word file with title page providing these details: assessment details
(Assignment 1 Part II) and student details (name and the student ID). Include the code that has been reviewed.
● Save your file(s) into a zip file called AssignmentDetailsStudentID.zip (e.g. Assignment1Part1s123456.zip
● Submit your zip file containing your entire submission to Moodle.
● Note that your assignment will NOT be accepted unless you have completed all of the steps mentioned above.
Part 3 submission
● Include a word file with title page providing these details: assessment details
(Assignment 1 Part III) and team details (name and the student ID of each member). If you have used any concept in your assignment that is not covered in the unit delivery. Then include the explanation of the concept with references.
● Save your file(s) into a zip file called AssignmentDetailsTeamDetails.zip (e.g. Assignment1Part3Team21.zip)
● Submit your zip file containing your entire submission to Moodle.
● Note that your assignment will NOT be accepted unless you have completed all of the steps mentioned above.
Late Submission
Unless an extension or special consideration has been granted, assignments submitted after the due date will receive a late-submission penalty of 10 percent of the available marks in that task. A further penalty of 10 percent of the available marks will be applied for each additional day (24- hour period including weekends and public holidays), or part thereof, the assessment task is overdue. This applies to all the parts of the assignments.
Assignments submitted 7 days after the due date will NOT be accepted and will receive a mark of zero. Students may not receive feedback on any assessments that receive a mark of zero due to a late-submission penalty.
Assessment weighting
This assignment contributes 20% to your final mark.
● Individual work: 10%
● Code review: 5%
● Combined group work: 5%
Case Study:
TravelPlus Airlines, a leading international airline, aims to enhance its customer loyalty programs, improve passenger satisfaction, and advance its sustainability efforts. The airline has accumulated extensive data on frequent passengers, which includes the number of flights taken, total spending on airline services, distance travelled, and other related factors.
To leverage this data effectively, TravelPlus Airlines is analysing various metrics that can inform their business decisions. By calculating key metrics such as passenger tier, loyalty scores, carbon footprint, and trip value index, the airline can classify customers into loyalty tiers, offer personalised rewards, assess the environmental impact of frequent travellers, and evaluate the overall value that each passenger brings to the company.
This analysis will allow TravelPlus Airlines to better understand their frequent flyers, reward high- value passengers, and create more tailored services and incentives. It will also enable the company to track its environmental performance and ensure that it is meeting its sustainability goals.
Dataset = [[name, phone, email, noOfFlights, kmsTravelled, totalSpending, maxSpending]]
dataSet =
[ ["John Smith", "5551234567", "[email protected]", 45, 68000, 12500, 900],
["Sarah Johnson", "5559876543", "[email protected]", 30, 50000, 9700, 750],
["Michael Williams", "5555678901", "[email protected]", 60, 85000, 15200, 1100], ["Emily Davis", "5553456789", "[email protected]", 20, 25000, 4800, 600],
["William Brown", "5558765432", "[email protected]", 55, 92000, 14800, 950],
["Olivia Martinez", "5556543210", "[email protected]", 38, 65000, 10300, 850],
["James Garcia", "5552345678", "[email protected]", 42, 70000, 11600, 950],
["Isabella Miller", "5558901234", "[email protected]", 25, 40000, 7200, 700],
["Ethan Wilson", "5557890123", "[email protected]", 35, 60000, 9900, 850],
["Charlotte Moore", "5556789012", "[email protected]", 50, 80000, 13800, 1000], ]
Part 1 Individual Code Writing (10%)
Each team member is responsible for completing ONLY one section.
Section 1 - Tier Classification:
Tier classification refers to assigning passengers into different loyalty tiers (e.g., Bronze, Silver, Gold, etc.) based on their total spending and the number of flights they've taken. The airline uses tier classification to segment their customers and offer rewards based on loyalty. Higher tiers typically receive more benefits, such as priority boarding, free upgrades, or extra baggage allowance. This encourages passengers to fly more often and spend more to attain a higher tier, enhancing customer retention and loyalty.
The calculation is done using the formula:
tier_score = totalSpending * factor 1 + noOfFlights * factor 2
where factor1 = 1.0
factor2 = 2.0
The score is then used to classify passengers into various tiers as follow:
• Breeze Beginner : Score below 0 and 4999
• Turbo Traveller: Score below 5000 and 9999
• Supersonic Sailor: Score below 10000 and 10999
• Sky High Hero: Score below 11000 and above
Instructions:
• Write a function calculate_tier(dataset) that calculates the tier for each passenger using the formula above.
• Update the dataset with a new field tier based on the classification. Ensure that the tier is categorised as above, as per their score as described above.
• Format all values to two decimal values
• Print the updated dataset.
Section 2 - Loyalty Score:
The Loyalty Score is a numerical value that helps the airline gauge a passenger's overall engagement with the airline. A high loyalty score indicates a frequent and high-spending customer, valuable for revenue generation. This score helps airlines tailor exclusive promotions, discounts, or offers to their most loyal customers. It also provides insights into which passengers are most likely to respond positively to targeted marketing efforts, allowing the airline to personalise its services.
The calculation is done using the formula and case below:
loyalty_score = spendingPerFlight * noOfFlight/2
where, spendingPerFlight = totalSpending/noOfFlights
If noOfFlights is greater than or equal to 5:
We add a bonus value to the score, the bonus value is calculated using the formula below:
bonus = (noOfFlights - 5) * kms/(spending * noOfFlights)
Instructions:
• Write a function calculate_loyalty_score(dataset) to compute the loyalty score using the provided formula. Don’t forget to add a bonus for any user who has completed more than 5 flights.
• Add a new field loyalty_score to the dataset.
• Format all values to two decimal values
• Print the updated dataset.
Section 3 - Carbon Footprint
Carbon footprint is the measure of carbon dioxide emissions associated with a passenger's travel. With increasing global awareness of climate change, many airlines are now tracking their carbon footprints as part of sustainability initiatives. Calculating carbon footprints for individual passengers allows the airline to assess its overall environmental impact and find ways to reduce it. Additionally, this information can be used to offer customers carbon offset options or reward environmentally conscious passengers who choose more sustainable travel practices.
The calculation is done using the formula below:
carbon_footprint = noOfFlights * averageDistancePerFlight * 0.09
Where: averageDistancePerFlight = kmsTravelled/ noOfFlight and 0.09 is a multiplier.
The score is then used to classify the footprint into various categories as follow:
• Low: 0 - 2000 kg
• Medium: 2001 - 4000 kg
• High: 4001 kg and above
Instructions:
• Write a function calculate_carbon_footprint(dataset) that calculates the carbon footprint for each passenger using the formula above.
• Update the dataset with a new field carbon_footptint based on the classification. Ensure that the carbon_footprint is categorised, as above as their carbon_footprint score as described above.
• Format all values to two decimal values
• Print the updated dataset.
Section 4 - Trip Value Index
The Trip Value Index (TVI) measures the overall value a passenger brings to the airline by combining financial metrics with service usage. The Trip Value Index helps airlines identify high- value passengers who may not be frequent flyers but still contribute significantly through long- distance travel or higher spending on premium services. This metric can inform decisions about who to prioritise for rewards, upgrades, or special offers. It also helps in identifying potential VIP customers for premium services or targeted loyalty programs.
The calculation is done using the formula below:
TVI = spendingPerFlight - maxSpending/100
where, spendingPerFlight = totalSpending/noOfFlights
The score is then used to classify the TVI into various categories as follow:
• Low: -500 to 0
• Medium: 1 to 100
• High: 101 and above
Instructions:
• Write a function calculate_tvi (dataset) that calculates the TVI for each passenger using the formula above.
• Update the dataset with a new field TVI based on the classification. Ensure that the TVI is categorised, as above as their TVI score as described above.
• Format all values to two decimal values
• Print the updated dataset.
Part 2 Individual - Peer code review (5%)
Each member of the team is required to review the code written by one of the other members of the team in a way that everyone’s code is reviewed. You could use the following checklist to perform your code review.
Use the checklist provided below to ensure you have completed all parts of the review.
|
Criteria |
Yes/No |
Comments |
1 |
File header comments present |
□ |
|
2 |
Function header comments present |
□ |
|
3 |
Doc strings present |
□ |
|
4 |
Proper indentation |
□ |
|
5 |
Proper spacing |
□ |
|
6 |
Meaningful function and variable names |
□ |
|
7 |
Efficient programming practices used |
□ |
|
8 |
Redundant code present |
□ |
|
9 |
Modular programming approach used |
□ |
|
If the program has errors then include the following information in your report:
• Line number in which the error exists
• Type of error
• Suggestions to fix the error
Note: In your submission, provide clear information about the team members code that you have reviewed. In your submission include a copy of the code that you have reviewed. If not included you will be awarded a ZERO mark.
Part 3: Combined Group work (5%)
Combine all the sections and implement the following:
Write a function that will display a menu with the following options:
1. Calculate Tier Classification
2. Calculate Loyalty Score
3. Calculate Carbon Footprint
4. Calculate Trip Value Index
5. Get Customer Value Ranking
6. Exit
Get Customer Value Index
The final task for the group involves creating a comprehensive function that aggregates all the previous calculations—Tier Classification, Loyalty Score, Carbon Footprint, and Trip Value Index— into a single metric known as the Customer Value Ranking (CVR). This ranking will help TravelPlus Airlines to evaluate passengers holistically, allowing the airline to understand the overall value each passenger brings, based on their loyalty, environmental impact, and monetary contributions.
Develop a function named calculate_CustomerValueRanking(dataset) that takes the dataset and incorporates the results from the previous individual calculations: Tier Classification, Loyalty Score, Carbon Footprint, and Trip Value Index. The function will generate a final score (CVR) for each passenger by combining these four metrics and ranking passengers accordingly.
Steps to Complete:
1. Retrieve Calculations: Gather the results of each individual calculation from the dataset.
2. Weight Factors: Assign specific weights to each calculation, based on the importance the airline places on them.
a. Tier Classification: 20% or 0.2
b. Loyalty Score: 35% or 0.35
c. Carbon Footprint: 25% or 0.25
d. Trip Value Index: 20% or 0.2
3. Final CVR Calculation: Sum the weighted contributions to produce the final Customer Value Ranking score for each passenger.
cvr = tier_score + loyalty_score + carbon_score + tvi_score
● tier_score = [Tier_value] * weight_factors, where Tier_Value is as follows based on their Tier classification:
Tier |
Tier Value |
Breeze Beginner |
1 |
Turbo Traveller |
2 |
Supersonic Sailor |
3 |
Sky High Hero |
4 |
● Loyalty_score = loyalty_value * weight_factors, where loyalty_score is calculated from the calc_loyalty_score function.
● Carbon_score = [carbon_value] * weight_factor, where carbon_value is as follows based on Carbon_footprint score classification:
Classification |
Carbon_Value |
Low |
3 |
Medium |
2 |
High |
1 |
• tvi_score = [tvi_value] * weight_factor, where tvi_value is as follows based on TVI_score classification:
Classification |
TVI_Value |
Low |
1 |
Medium |
2 |
High |
3 |
4. Append: The function will append the CVR score as a new column to the dataset
5. Ranking: Sort the passengers in the dataset based on their CVR scores, with the highest score representing the most valuable customer to the airline.
6. Output: Print the updated datasheet.