Question: PLEASE HELP ME SLOVE THIS PYTHON PROGRAM Python Code (+25) We will use the functions from Lab 11 Populate an array of size n =

PLEASE HELP ME SLOVE THIS PYTHON PROGRAM

Python Code (+25)

We will use the functions from Lab 11

Populate an array of size n = 20 with random integers in the range 10 ---- 50 inclusive (see Lab 06 and lab 11) but do NOT include any duplicates. The list of n integers should include only unique integers in the range 10 25

Strategy

Generate a random integer (1)

If it NOT in the list add to the list

Else return to (1) that is generate another random integer

USE the fill() function in the template below

Display the list using the display() function from Lab 11 function

Display the list in sorted order (largest to smallest) by calling a function sorted that you code Use the sorted() function in the template

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

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

Display the number of integers that are evenly divisible by 3 (no remainder) using your function div3() . Integers in the array that are evenly divisible be 3 are { 12, 15, 18, 21, 24}

Please use x mod 3 as in

Select an integer from your list call it x. If x mod 3 == 0 then add 1 to a counter

Use the div3() in the template

Display the number of integers in the list that are multiples of 5 (10, 15, 20,25) by coding a function mult5()

Use the mult5() in the template

Ask the user for an integer and display YES if the integer appears in the list or NO if it is in the list by calling the yesNo() function as noted in the lab

TEMPLATE to USE

import random def display(a): print("the list == ", a) # DONE def sorted (a): # sort the array a from largest to smallest # Consider using the python sort function return a def fill(a,n): # fill the list a with n random integers in the range 10 --- 25 inclusive BUT NO duplicates THIS code NEEDS to be fixed ar = 10 br = 25 j = 0 while (j < n): # populate the array using the while loop x = random.randint(ar, br) # Return a random integer . a.append(x) j = j + 1 return a

def div3 (a): v = -5 return v def multi5(a): m = 11 return m def yesNo(a): s = "yes" return s def max(a): # return the largest value in the list mx = a[0] # place holder only return mx def min(a): # return the smallest value in the list mn = a[-1] return mn # ========================================== # NOW we call the functions a = [] n = 20 # array size array = fill(a,n) display(array) mx = max(array) mn = min(array) d = div3(array) m = multi5(array) print( "Maximum is : ", mx, "Minimum is :", mn) print( "div3 return is : ", d, " multi5 return value is :", m) str = yesNo(array) print(str)

OUTPUT

the list == [15, 20, 14, 21, 22, 24, 22, 13, 10, 25, 12, 17, 17, 13, 25, 12, 14, 16, 23, 13]

Maximum is : 15 Minimum is : 13

div3 return is : -5 multi5 return value is : 11

yes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!