Could you guys provide the python code for this? 1. Populate a list of size n =
ID: 3815909 • Letter: C
Question
Could you guys provide the python code for this?
1. Populate a list of size n = 50 with random integers in the range 10 ---- 25 inclusive.
2. Display the list using the display() function Already done
3. Display the sum of all the integers in the list using your function sum()
4. Display the list in sorted order (largest to smallest) by calling a function sorted***
5. Display the minimum integer in the list using your function min()
6. Display the maximum integer in the list using your function max()
7. Display the average of the integers in the list using your function ave()
8. Display the number of even integers using your function evens() and the number of odd integers (odds == n – evens() )
9. Display the number of integers in the list that have 1 as their first digit i.e how many integers are equal to either 10, 11, 12, 13, 14, 15, 16, 17 18, or 19 call the digit10x()
10. Ask the user for an integer and display the number of times the integer appears in the list by calling the nCount() function
NOTES:
1. Use the template below and implement the functions as noted. Currently these functions have dummy code simply to illustrate return values and parameters.
2. Many of the function code is INCORRECT and needs to be fixed
Cut and paste the above template between the ====== and load into python editor and run the code
# Function definitions that need to be implemented. See a run of the code below
=======================================================================
def display(a):
print("the list == ", a) # DONE
def max(a):
# return the largest value in the list
max = a[0] # place holder only
return max
def min(a):
# return the smallest value in the list
min = a[-1]
return min
def ave(a):
# return the average of the integers in the list
#must call the sum() function here
average = a[-2]
return average
def sum(a):
# return the sum of the integers in the list
#it will be used in the ave() function
s = 10000
return s
def evens(a):
# return the number of even integers
e = 100 # WRONG fix this
return e
def digit10x(a):
# return the number of integers that have 1
# in the first digit i.e. how many integers are equal to
# 10, 11, 12, 13 ….or 19
x10 = 22
return x10
def nCount(a,n):
# return the number of times n appears in the list a
x = 10000
return x
# NOW we call the functions
a = ( 22, 3, 78, -6)
display(a)
mx = max(a)
mn = min(a)
average = ave(a)
s = sum(a)
print( "Maximum is : ", mx, "Minimum is :", mn)
print( "average is : ", average, " sum is :", s)
n = int(input("please enter a search integer "))
c = nCount(a,n)
print("the number of times ", n, " is in the list : ", c)
e = evens(a)
print("the number of even integers is: ", e, " and the number of odd is:??? " )
x = digit10x(a)
print("the number of integers that start with a 1 is: ", x)
OUTPUT from a run of the above code
the list == (22, 3, 78, -6)
Maximum is : 22 Minimum is : -6
average is : 78 sum is : 10000
please enter a search integer 88
the number of times 88 is in the list : 10000
the number of even integers is: 100 and the number of odd is: ???
the number of integers that start with a 1 is: 22
Explanation / Answer
1Ans]
2Ans]
syntax:argument variations: display(terminal)
display(start, terminal)
display(start, terminal, step_size)
3Ans]