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

5050 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Use recursion to print all the sublists of a given list


Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".


How do I use for loops in Python?


Write a short program to print all the even numbers 1 to 100


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences