Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.

Import numpy

originalArray = numpy.range(100)

split1 = originalArray[:len(originalArray)/2] #The use of a :X as an index into an array means that you want all values from the start to the Xth value

split2 = originalArray[len(originalArray)/2:] #The use of a X: as an index into an array means that you want all values from the Xth value to the end

SH

Related Python Mentoring answers

All answers ▸

How would you write a while loop to print all even numbers from 1-10?


What's the difference between a local and a global variable?


Write a simple Python program that asks a user to input their age and name and then return the text: "Hi my name is *NAME*, and I am *AGE* years old."


Write a program that computes the sum of all numbers up to a input number n