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

4980 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a cycle "if" and "while"?


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


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


What are the main data structures that I can use in Python


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences