basic constructions for in range( + ) + * print executing this code will print the number to the screen note in particular how the accumulation variable is initialized to zero the value of then gets updated with each iteration of the loopand not until the loop is finished will have the correct value this way of building up the value is very common in programmingso make sure you understand it by simulating the code segment above by hand it is technique used with loops in any programming language while loops python also has another standard loop constructionthe while loopdoing iterations with loop index very much like the for loop to illustrate what such loop may look likewe consider another modification of ball_plot py in sect we will now change it so that it finds the time of flight for the ball assume the ball is thrown with slightly lower initial velocitysay : ms while everything else is kept unchanged since we still look at the first second of the flightthe heights at the end of the flight become negative howeverthis only means that the ball has fallen below its initial starting positioni the height where it left the handso there is no problem with that in our array we will then have series of heights which towards the end of become negative let usin program named ball_time py find the time when heights start to get negativei when the ball crosses the program could look like this from numpy import linspace linspace( * * * ** initial velocity acceleration of gravity points in time interval generate all heights find where the ball hits = while [ > + nowy[ - ]> and [ ]< so let' take the middle point in time as the approximation for when the ball hits = print " = at" *( [ - [ ]we plot the path again just for comparison import matplotlib pyplot as plt plt plot(typlt plot( * ' --'plt xlabel('time ( )'plt ylabel('height ( )'plt show(