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 ▸

Give a segment of python code that will print the numbers 1 to 7, each one on a new line


Write a function that takes a string, and outputs that string formatted in camelcase. (alternating upper and lower case for each character, e.g. cAmElCaSe)


Write a program that takes a value x and then outputs x Fibonnaci numbers. E.g. if x=6 output would be 1 1 2 3 5 8


What are docstrings and how do I use them to improve my code readability?