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
Answered by Sameh H. Python tutor

5233 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a FOR loop and WHILE loop and how do I write them?


Explain why creating a list of several instances of one element using something like my_list = [a] * 5 can result in strange behaviour


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


How do For Loops work?


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2025 by IXL Learning