Last active
August 29, 2015 14:17
-
-
Save mariack/9afa7b06f690b74d6296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
INPUTS = [] | |
RESULTS = [] | |
def main(): | |
addToList() | |
a = len(INPUTS) | |
print("Count of List: ", a) | |
b = sum(INPUTS) | |
print("The sum of the list is: %d." % b) | |
c = avgList(INPUTS) | |
print("The average of the list is: %0.2f" % c) | |
minMax() | |
e = stdDev() | |
print("The standard deviation is: %0.3f" % e) | |
d = INPUTS.sort() | |
print("Sorted list: ", INPUTS) | |
RESULTS.insert(0, len(INPUTS)) | |
RESULTS.insert(1, sum(INPUTS)) | |
RESULTS.insert(2, avgList(INPUTS)) | |
RESULTS.insert(3, max(INPUTS)) | |
RESULTS.insert(4, min(INPUTS)) | |
RESULTS.insert(5, e) | |
print("The results are: ", RESULTS ) | |
def addToList(): | |
stop = False | |
while(not stop): | |
number = input("Enter a number to be put into a list. Enter 's' to end list: ") | |
if number == 's': | |
print("End of list.") | |
stop = True | |
else: | |
INPUTS.append(int(number)) | |
print(INPUTS) | |
def avgList(x): | |
avg = sum(x)/len(x) | |
return avg | |
def stdDev(): | |
deviationList = [] | |
avg = avgList(INPUTS) | |
for x in INPUTS: | |
s = (x - avg)**2 | |
deviationList.append(s) | |
m = sum(deviationList)/len(INPUTS) | |
sigma = math.sqrt(m) | |
return sigma | |
def minMax(): | |
maximum = INPUTS[0] | |
minimum = maximum | |
for x in INPUTS[0:]: | |
if (x > maximum): | |
maximum = x | |
elif (x < minimum): | |
minimum = x | |
print("The max number is: ", maximum) | |
print("The min number is: ", minimum) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment