Kindly assist to finalize python integer array.
import array
# Function definition
def myFunc(myArray):
print(myArray)
myArray = array.array('i', [for i in range(1, 1000)])
print(myArray)
myFunc(myArray)
The myArray has n integers, it should return max among all one-digit integers.
n is int from 1 to 100 each element in myArray is within range of -5 to 5
You could use list comprehension to build a list of random numbers from [-5, 5]
from a range of 1 to n
by following the example below.
To get the max number from the list, simply pass the list to the max
function.
import random
size = 10
value_min = -5
value_max = 5
arr = list(random.randrange(value_min, value_max + 1) for x in range(1, size))
print('List', arr)
print('Max', max(arr))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.