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

Write python function called createList that will create and fill a list of any

ID: 3818045 • Letter: W

Question

Write python function called createList that will create and fill a list of any size with random numbers in the range of 1 - 100. This function should take the size of the list as a parameter to the function. It should return the created list. Write a separate function called printList that will print a list of any size. This function should take the list to print as an argument. Write a third function called smallLarge which will search a list given to it and return back the smallest and largest value in the array. You will need to use a tuple to return multiple items. This function should take the list to search as an argument. In the main part of your program do the following Fill the list with 25 numbers using the createList function Print the List using the printList function Print the largest and smallest values in the array. Use the smallLarge function to get determine the small and large values. What not to do global variables input in any funciton print in any funciton other than main and printList MUST BE IN PYTHON

Explanation / Answer

# pastebin link of code in case indentation mess up: https://pastebin.com/rccNhLys

from random import randint
def createList (n):
created_list = []
for i in range(n):
created_list.append(randint(1, 100))
return created_list

def printList(lis):
print("["),
for l in lis:
print(l),
print("]")

def smallLarge(lis):
smallest = lis[0]
largest = lis[0]
for i in xrange(1, len(lis)):
if lis[i] < smallest:
smallest = lis[i]
if lis[i] > largest:
largest = lis[i]
return (smallest, largest)

if __name__ == '__main__':
lis = createList(25)
printList(lis)
(smallest, largest) = smallLarge(lis)
print("Smallest: " + str(smallest) + " Largest: " + str(largest))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote