-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsentences.py
More file actions
28 lines (24 loc) · 964 Bytes
/
sentences.py
File metadata and controls
28 lines (24 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Import any individual functions from outside packages
#that are used in your functions.
#These are called dependencies.
from statistics import mean
from statistics import median
#Function definitions with docstrings
def printMean(a_list):
'''Returns the mean of a list, rounded to the hundredths, in a complete sentence.'''
m = mean(a_list)
return f"The mean of the numbers provided is {round(m, 2)}."
def printSum(a_list):
'''Returns the sum of a list in a complete sentence.'''
s = sum(a_list)
return f"The sum of the numbers provided is {s}."
def printMedian(a_list):
'''Returns the median of a list in a complete sentence.'''
m = median(a_list)
return f"The median of the numbers provided is {m}."
#This if statement should be included at the end of any module
#If you don't include this, when you import the module, it will run
#the module script from top to bottom instead of only importing the
#functions
if __name__ == "__main__":
main()