In this assignment I am to make an array that is ranging fro
In this assignment, I am to make an array that is ranging from 1 to 500 numbers. So far, from this class example, it is designed to have the user input the amount of elements. I want to change that to the objective of 1 to 500. How can I do that from what I\'m showing in the picture?
More importantly, how do I display the highest AND lowest number from the array (of 1 to 500) along with displaying the FIRST time it is displayed in the array, since there\'s a chance that the highest and lowest can be displayed more than once?
Python by the way.
File BIG ARRAY ASSIGN. HALogic Desi 16-17My work BIG ARRAY ASSIGN B52 py Edit Format Run Options Window Hel import random def main elements int (input (\"size of list? numGroup (01 elements setArr (numGroup, elements) Print array contents print (\"numGroup array content\") for i in range (len (numGroup) print (\"numGroupt\", i, \"1 num Group lil, sep print (\"Sum of the values calcTotal (numGroup)) print (\"Average of the array\'s values findAvr (elements,numGroup) print (\"Highest value in the array findMax (numGroup) AnIt\'s first location print (\"Lowest value in the array findLow (numGroup) \"VnIt\'s first location def see tArr (arr size) for i in range (size) arr tij random. randrange (1, 100) clef calcTotal (arr) total 0 for i in range (len (arr) total arr [i] return total det find Avr (elements, arr) total i range (len (arr) total total/elements average average findMax (arr) high arr en (arr) i range high arr til til high arrSolution
import random
def main():
##elements = int(input(\"Size of the list?\"))
for elements in range(1,500):
numGroup=[0]*elements
setArray(numGroup,elements)
#print array contents
print(\"numGroup array content\")
for i in range(len(numGroup)):
print(\"numGroup[\",i+1,\"]=\",numGroup[i],sep=\'\')
print(\"Sum of the values:\",calcTotal(numGroup))
print(\"Average of the array\'s values\",findAvr(elements,numGroup))
print(\"Highest value in the array:\",findMax(numGroup),\"\ It\'s first location:\")
print(\"Lowest value in the array:\",findLow(numGroup),\"\ It\'s first location:\")
def setArray(arr,size):
for i in range(size):
arr[i]=random.randrange(1,100)
def calcTotal(arr):
total=0;
for i in range(len(arr)):
total+=arr[i]
return total
def findAvr(elements,arr):
total=0
for i in range(len(arr)):
total+=arr[i]
average=total/elements
return average
def findMax(arr):
high=arr[0]
for i in range(len(arr)):
if arr[i]>high:
high=arr[i]
return high
def findLow(arr):
low=arr[0]
for i in range(len(arr)):
if arr[i]<low:
low=arr[i]
return low
main()

