Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

could somebody provide the python code for this? thank you, thumbs up! Write a p

ID: 3816438 • Letter: C

Question

could somebody provide the python code for this? thank you, thumbs up!

Write a python program able to do the following:

Populate a list of size n = 50 with random integers in the range 10 ---- 25 inclusive

Display the list using the display() function

Display the sum of all the integers in the list using your function sum()

Display the list in sorted order (largest to smallest) by calling a function sorted***

Display the minimum integer in the list using your function min()

Display the maximum integer in the list using your function max()

Display the average of the integers in the list using your function ave()

Display the number of even integers using your function evens() and the number of odd integers (odds == n – evens() )

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()

Ask the user for an integer and display the number of times the integer appears in the list by calling the nCount() function

Explanation / Answer

Here is the code for the first 4 methods:

#!/usr/bin/python

#1. Populate a list of size n = 50 with random integers in the range 10 ---- 25 inclusive
def populateRandom(size):
   myList = [0] * size
   for i in range(size):
       from random import randint
       myList[i] = randint(10,25)
   return myList
      
#2. Display the list using the display() function (Already done)
def display(a):
print("the list == ", a) # DONE

#3. Display the sum of all the integers in the list using your function sum()
def sum(a):
# return the sum of the integers in the list
#it will be used in the ave() function
s = 0
for i in range(len(a)):
   s += a[i]
return s

#4. Display the list in sorted order (largest to smallest) by calling a function sorted***    
def sorted(a):
   for i in range(len(a)):
       for j in range(len(a) - i - 1):
           if a[j] < a[j+1]:
               temp = a[j]
               a[j] = a[j+1]
               a[j+1] = temp
   return a

# NOW we call the functions

a = populateRandom(50)

display(a)

total = sum(a)
print 'The sum of elements is: ', total

sortedList = sorted(a)
print 'Sorted list is: ',
display(sortedList)