Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CITX1401 Computational Thinking with Python

Project 1 Trimester 2 2023 (Individual project)

Submission deadline: 

Project description:

You should construct a Python 3 program containing your solution to the following problem and submit your program electronically on Moodle (you should also submit a copy on Blackboard as a backup). The name of the file containing your code should be your student ID e.g. 12345678.py No other method of submission is allowed. Please note that this is an individual project. Your program will be automatically run on moodle for sample test cases provided in the project sheet if you click the “check” link. However, your submission will be tested thoroughly for grading purposes after the due date. Remember you need to submit the program as a single file and copy-paste the same program in the provided text box. You have only one attempt to submit so don’t submit if you are not satisfied with your attempt. All open submissions at the time of the deadline will be automatically submitted. There is no way in the system to open the closed submission and reverse your submission.

You are expected to have read and understood the University’s guidelines on academic conduct. In accordance with this policy, you may discuss with other students the general principles required to understand this project, but the work you submit must be the result of your own effort. Plagiarism detection, and other systems for detecting potential malpractice, will therefore be used. Besides, if what you submit is not your own work then you will have learnt little and will therefore, likely, fail the final exam.

You must submit your project before the deadline listed above. Following UWA policy, a late penalty of 5% will be deducted for each day (or part day), after the deadline, that the assignment is submitted. No submissions will be allowed after 7 days following the deadline except approved special consideration cases.

Project Overview:

You are required to write a Python 3 program that will read a CSV file. After reading the file, your program is required to complete the following statistical tasks:

1. Calculate the Mean of a given dataset

2. Calculate the Standard Deviation of a given dataset.

3. Calculate the Median of a given dataset.

4. Calculate the Mode of a given dataset.

Note there are multiple CSV files, only one is provided for testing (rainfall.csv). The rainfall (and other files) consists of rainfall data for Perth (Western Australia) over the past 29 years. The data is organised in the file as follows. Each line represents one year, the first number being the year, the next Jan, Feb and so on:

Year,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec

Each function should be independent of the other functions. You will need a function to open the file and load the dataset. Make sure you use the function names provided with the correct parameter definitions.

You should use the following code as a starting point:

def calcMean(filename, start, end, by):

# inputs: filename: name of the file (string);

# start, end: year (int); by: Year or Jan, Feb… (string)

# processing: calculates the mean of the data set

# outputs: mean (float) rounded to 2 decimal places

def calcStdDev(filename, start, end, by):

# inputs: filename: name of the file (string);

# start, end: year (int); by: Year or Jan, Feb… (string)

# processing: calculates the standard deviation of the data set

# outputs: standard deviation (float) rounded to 2 decimal places

def calcMedian(filename, start, end, by):

# inputs: filename: name of the file (string);

# start, end: year (int); by: Year or Jan, Feb… (string)

# processing: calculates the median of the data set

# outputs: median (float) rounded to 2 decimal places

def calcMode(filename, start, end, by):

# inputs: filename: name of the file (string);

# start, end: year (int); by: Year or Jan, Feb… (string)

# processing: calculates the mode of the data set

# outputs: mode (float) rounded to 2 decimal places

Requirements:

1. You are not allowed to import any external or internal module in python. While use of many of these modules, e.g. csv or math is a perfectly sensible thing to do in production setting, it takes away much of the point of different aspects of the project, which is about getting practice opening text files, processing text file data, and use of basic Python structures, in this case lists and loops.

2. Ensure your program does NOT call the input() function  at  any time. Calling the input() function will cause your program to hang, waiting for input that automated testing  system  will  not  provide  (in fact,  what will  happen  is that  if the  marking program detects the call(s), it will not test your code at all which may result in zero grade).

3. Your program should also not call print() function at any time except for the case of graceful termination (if needed). If your program has encountered an error state and is exiting gracefully then your program needs to return zero as the value for the correlation otherwise empty list and print an appropriate message. At no point should you print the program’s outputs instead of (or in addition to) returning them or provide a printout of the program’s progress in calculating such outputs.

4. Do not assume that the input file names will end in .csv. File name suffixes such as .csv and .txt are not mandatory in systems other than Microsoft Windows. Do not enforce that within your program that the file must end with a .csv or any other extension (or try to add an extension onto the provided csv file argument), doing so can easily lead to loosing marks.

Input:

Your program must define the functions with the following syntax:

def calcMean(filename, start, end, by):

def calcStdDev(filename, start, end, by):

def calcMedian(filename, start, end, by):

def calcMode(filename, start, end, by):

Note start and end are years (int), they will be between 1994 and 2022 for the rainfall test set but do NOT assume the file will always be the same length. By (string) will determine if the function calculates by years or by a month entered. (All the values for that month hover the given years).

Output:

All returned numeric outputs (both in lists and individual) must contain values rounded to four decimal places (if required to be rounded off). Do not round the values during calculations. Instead round them only at the time when you save them into the final output variables.

Examples:

calcMean( “rainfall.csv”, 2000, 2005, year)

 #this would return the mean of the values occurring on those years.

Assumptions:

Your program can assume the following:

Anything that is meant to be string (e.g. filename) will be a string, and anything that is meant to be numeric will be numeric. Only year, jan, feb, mar… dec, will be entered in the by parameter.

The order of values in each row will follow the order given. No data will be missing in the CSV file; however, values can be zero and must be accounted for when calculating averages and standard deviations.

Important grading instruction:

Note that you have not been asked to write specific functions. The task has been left to you. Don’t forget the submission guidelines provided at the start of this document. Remember you will need a load function (and maybe others) consider everything we have learnt in class.

Marking rubric:

Your program will be marked out of 30 (10% of the total marks). 20 out of 30 marks will be awarded automatically based on how well your program completes a number of tests, reflecting normal use of the program, and also how the program handles various states including, but not limited to, different numbers of rows in the input file and / or any error states. You need to think creatively what your program may face. Your submission will be graded by data files other than the provided data file. Therefore, you need to be creative to look into corner or worst cases.  I have provided few guidelines from ACS Accreditation manual at the end of the project sheet which will help you to understand the expectations.

10 out of 30 marks will be awarded on style (6/10) “the code is clear to read” and efficiency (4/10) “your program is well constructed and run efficiently”. For style, think about use of comments, sensible variable names, your name at the top of the program, student ID, etc. (Please watch the lectures where this discussed)

Style Rubric:

0

Gibberish, impossible to understand

1-2

Style is really poor or fair

3-4

Style is good or very good, with small lapses

5-6

Excellent style, really easy to read and follow

Efficiency rubric:

0

Code too complicated to judge efficiency or wrong problem tackled

1

Very poor efficiency, additional loops, inappropriate use of readline ()

2

Acceptable efficiency with some lapses

3

Good efficiency with perhaps a minor lapse

4

Excellent efficiency, should have no problem on large files, etc.

Automated testing is being used so that all submitted programs are being tested the same way. Sometimes it happens that there is one mistake in the program that means that no tests are passed. If the marker is able to spot the cause and fix it readily, then they are allowed to do that and your - now fixed - program will score whatever it scores from the tests, minus 4 marks, because other students will not have had the benefit of marker intervention. Still, that's way better than getting zero. On the other hand, if the bug is hard to fix, the marker needs to move on to other submissions.

Extract from Australian Computing Society Accreditation manual 2019:

As per Seoul Accord section D, a complex computing problem will normally have some or all of the following criteria:

· involves wide-ranging or conflicting technical, computing, and other issues;

· has no obvious solution, and requires conceptual thinking and innovative analysis to formulate suitable abstract models;

· a solution requires the use of in-depth computing or domain knowledge and an analytical approach that is based on well-founded principles;

· involves infrequently-encountered issues;

· are outside problems encompassed by standards and standard practice for professional computing;

· involves diverse groups of stakeholders with widely varying needs;

· has significant consequences in a range of contexts;

· is a high-level problem possibly including many component parts or sub-problems;

· identification of a requirement or the cause of a problem is ill defined or unknown.

Necessary formulas: