Answer:
def maximum(aList):
highest = aList[0]
for number in aList:
if number > highest:
highest = number
return highest
def minimum(aList):
lowest = aList[0]
for number in aList:
if number < lowest:
lowest = number
return lowest
print(maximum([7, 5, 2, 3, 1, 8, 9, 4]))
print(minimum([7, 5, 2, 3, 1, 8, 9, 4]))
Step-by-step explanation:
Create a function named maximum that takes one parameter, aList
Initialize the highest as the first number in aList
Create a for loop that iterates through the aList. Compare each number in aList with highest. If a number is greater than highest, set it as new highest.
When the loop is done, return the highest
Create another function named minimum that takes one parameter, aList
Initialize the lowest as the first number in aList
Create a for loop that iterates through the aList. Compare each number in aList with lowest. If a number is smaller than lowest, set it as new lowest.
When the loop is done, return the lowest
Call the functions with given list and print the results