calculating the initial position for the cannonball is also easy it will start at distance and height we just need couple of assignment statements xpos ypos next we need to calculate the and components of the initial velocity we'll need little highschool trigonometry (seethey told you you' use that some day if we consider the initial velocity as consisting of some amount of change in and some amount of change in xthen these three components (velocityx-velocity and -velocityform right triangle figure illustrates the situation if we know the magnitude of the velocity and the launch angle (labeled thetabecause the greek letter th is often used as the measure of angles)we can easily calculate the magnitude of xvel by the equation xvel velocity cos theta similar formula (using sin thetaprovides yvel ty oci theta yvel velocity sin(thetaxvel velocity cos(thetafigure finding the and components of velocity even if you don' completely understand the trigonometrythe important thing is that we can translate these formulas into python code there' still one subtle issue to consider our input angle is in degreesand the python math library uses radian measures we'll have to convert our angle before applying the formulas there are radians in circle ( degrees)so theta *angle this is such common conversion that the math library provides convenient function called radians that does this computation these three formulas give us the code for computing the initial velocitiestheta math radians(anglexvel velocity math cos(thetayvel velocity math sin(thetathat brings us to the main loop in our program we want to keep updating the position and velocity of the cannonball until it reaches the ground we can do this by examining the value of ypos while ypos > used >as the relationship so that we can start with the cannonball on the ground ( and still get the loop going the loop will quit as soon as the value of ypos dips just below indicating the cannonball has embedded itself slightly in the ground