## Transcribed Text

Assignment
This Homework Assignment is designed to develop your ability create functions that
operate on numeric list by perform simple mathematical (statistical) operations.
We will use the concepts of Descriptive Statistics as the theme for this assignment.
Python
provides some built- - in statistical functions such as sum, max, min, etc. you
may not utilize these built-in functions in your code create your own version of
these functions as needed.
Create a single Python script [yourLastName]HW3 and solve each of the specified
problems.
Objectives
Define functions that encapsulate statistical concepts.
Task #
Description
Operation
o
Create a Numeric List of Values from a File
List Creation
Determine the maximum value in a numeric list
Determine the minimum value in a numeric list
List Range
1
Determine the range of a numeric list
Values
Determine the midrange of a numeric list
Determine the percentile of a numeric list
Calculate the sum of the values in a numeric list
Calculate the product of the values in a numeric list
Calculate the mean value of a numeric list
List
2
Calculate the variance of a numeric list
Descriptive
Values
Calculate the standard deviation of a numeric list
Calculate the median of a numeric list
Calculate the mode of a numeric list
Task O: File to List
Task
Description
Create a function named createNumberListFromFile which accepts a file path as its only
O
parameter and returns a numeric (float) list
2
3 def createNumberListFromFile(FP) :
4
data = []
5
with open(FP, 'r') as f:
6
for i in f:
We will use files in which
7
n = i.split()
the numbers are separated
by a single space
8
for j in n:
9
a = float(j)
10
data.append(a)
11
return data
12
Task 1 (List Range Values)
Subtask
Description
A
Create a function named maxList which accepts a numeric list as its only parameter and
returns the maximum value in the list
Create a function named minList which accepts a numeric list as its only parameter and returns
B
the minimum value in the list
Create a function named rangeList which accepts a numeric list as its only parameter and
C
returns the difference between the largest value in the list and the smallest value in the list
Create a function named midrangeList which accepts a numeric list as its only parameter and
D
returns the half the range value in the list
Create a function named percentileList which accepts a numeric list and a value (percentile) as
E
its parameters and returns the value in the list that corresponds to the specified percentile
Task 2 (List Descriptive Values)
Subtask
Description
A
Create a function named sumList which accepts a numeric list as its only parameter and returns
the sum of all the values in the list
Create a function named productList which accepts a numeric list as its only parameter and
B
returns the product of all the values in the list
Create a function named meanList which accepts a numeric list as its only parameter and
C
returns the average of all the values in the list
Create a function named varianceList which accepts a numeric list as its only parameter and
D
returns the between all the values in the list
Create a function named standardDeviationList which accepts a numeric list as its only
E
parameter and returns the standard deviation of all the values in the list
Create a function named medianList which accepts a numeric list as its only parameter and
F
returns the median value of the values in the list
Create a function named modeList which accepts a numeric list as its only parameter and
G
returns the value of the mode of the list
Objectives
Define functions that statistically analyze numeric data files.
Task #
Description
Operation
3
Write a numeric list to a File
File Creation
Calculate the Frequency of a value in a numeric file
Calculate Relative Frequency of a value in a numeric file
Frequency
4
Analysis
Calculate Cumulative Relative Frequency of a value in a numeric file
Create a list of Outlier Values in a numeric File
Outlier Analysis
5
Remove Outliers Values from a numeric File
Distribution
6
Determine the shape of the Distribution of values in a numeric file
Analysis
Task O: List to File
Task
Description
Create a function named createNumericFileFromLis which accepts a file path and a list as
3
parameters and creates a file of space-separated values from the values in the
specified
list
13 def createNumericFileFromList (FP, L)
:
14
with open(FP, 'w') as f:
15
for i in L:
16
f.write (str (i) +
17
Our files will contain a
space between each value
vTask 4: Frequency Analysis
Subtask
Description
Create a function named frequencyList which accepts a file path and a value as parameters
and
A
returns the frequency of that value in the numeric file
Create a function named relativeFreqList which accepts a file path and a value as parameters
B
and returns the relative frequency of that value in the numeric file
C
Create a function named cumRelativeFreqList which accepts a file path and a value as
parameters and returns the cumulative relative frequency of that value in the numeric file
Understanding Frequency
Utilize the sort() method on the
Frequency
The number of times a value occurs in a list
list to simplify the frequency
analysis
Relative
The frequency of a value in a list divided by the
Frequency
total number of values in the list
The relative frequency for a value in a list plus
Cumulative
the cumulative relative frequency of the
Relative
previous value in the list.. the last cumulative
Frequency
relative frequency for the last value is always 1
Task 5: Outlier Analysis
Subtask
Description
A
Create a function named OutlierList which accepts a file path as its only parameters and
returns a list of all the outlier values of the values in the numeric file
Create a function named removeOutliers which accepts two file paths as its parameters (input
B
file, output file) and creates a new file (output file) with all the outlier values of the values in the
numeric file removed
Understanding Outliers
A value in a list is considered an outlier value if it is greater than the lower outlier limit and
less than the upper outlier limit (inclusive)
Lower Outlier Limit = 25th percentile of the list - 1.5 X interquartile range of the list
Upper Outlier Limit = 75th percentile of the list - 1.5 X interquartile range of the list
Interquartile Range = 75th th percentile of the list - 25th percentile of the list
Task 6: Distribution Analysis
Task
Description
Create a function distribution Shape which accepts a file path as its only parameter and
3
determines the shape of the distribution of values in the numeric file based on the following
rules:
Value
Shape
Mean > Median
'Right Skewed'
Mean < Median
¹Left Skewed'
Mean = Median
`Symmetrical'

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

# Task 0: File to List

# function named createNumberListFromFile which accepts a file path as its only

# parameter and returns a numeric (float) list

def createNumberListFromFile(path):

data = []

with open(path) as file: # read the file

for i in file: # iterations over all lines of file

n = i.split() # split the line so we get numbers

for j in n: # iteration over numbers

a = float(j) # convert to float

data.append(a)

return data

# Task 1 (List Range Values)

# functions maxList, minList, rangeList and mideRangeList are

# quite streightforward to define, only basic python functions such as max, min and sorted are used

def maxList(L):

L_max = max(L)

return L_max

def minList(L):

L_min = min...