In: Computer Science
Python
A survey gathers heights and weight of 50 participants and recorded the participants age as ages=[40,56,46,58,79,70,67,46,32,91,92,93,47,95,69,56,50,30,9,29,29,0,31,21,14,18,16,18,76,68,6,9,78,81,71,91,01,69,78,77,54,59,59,41,51,48,49,76,10]
upd: do anything in Python using everything in the question
Note: If you require code for any other functionality please leave a comment.
A python code incorporating the above lists is as follows:
# function to find minimum value
def findMin(lis):
return min(lis)
# function to find maximum value
def findMax(lis):
return max(lis)
# function to find mean value
def findMean(lis):
return sum(lis) / len(lis)
# given the list of ages
ages = [40, 56, 46, 58, 79, 70, 67, 46, 32, 91, 92, 93, 47, 95, 69, 56, 50, 30, 9, 29, 29, 0, 31, 21, 14, 18, 16, 18,
76, 68, 6, 9, 78, 81, 71, 91, 1, 69, 78, 77, 54, 59, 59, 41, 51, 48, 49, 76, 10]
"""
We are going to find out the minimum age, maximum age
and the mean age of all the people surveyed.
We can pass the other lists of weights and height
to find minimum, maximum and mean weight and height.
"""
print("Minimum age is : ", end="")
print(findMin(ages))
print("Maximum age is : ", end="")
print(findMax(ages))
print("Mean age is : ", end="")
print(findMean(ages))
We are finding out the minimum maximum and the mean values of the list.
We can define similar functions to create more functionalities.
Screenshot of above code for reference:
Secreenshot of output :