Question: The purpose of this question is to write a python program (script) that manipulates arrays using vector arithmetic. You will compute the values of points



The purpose of this question is to write a python program (script) that manipulates arrays using vector arithmetic. You will compute the values of points on an ellipse. The ellipse has a major axis whose length is a and a minor axis whose length is b. For any point (x,y) on the ellipse the following should be true. .x 1= y? a b Write a function that begins with the header: def getNumber (prompt): The function repeatedly asks for a number (either a float or an int), by displaying the prompt, until the user enters a valid number. The function returns the number entered by the user Hint: Strip the leading and trailing whitespace from the input from the user. If value is the value returned by input the function must perform the following tests: if value is not a float or an int display the value of value and the message 'is not a number!'. if eval(value, (). {}) causes an exception display the message 'Invalid input!". if value is an empty string (that is the user did not type anything in and pressed return/enter) display the message 'Missing input!' Note: You should be able to modify a function from lab 6 to do this. Write a function that begins with the header: def yOnEllipse(a, b, xValues): This function is given the lengths of the major and minor axes and an array of X values. It must compute and return a new array of Y values using vector arithmetic where each element in the new array is computed using the formula x y=b1- where a is the length of the major axis, b is the length of the minor axis and x is an element of the array of x values. Each value of (x,y) is a point on the ellipse. Note: You must NOT use for or while in this function. Write a function that begins with the header: def verifyPoints(a, b, xValues, yValues): ,2 + This function uses vector arithmetic to compute and return an array where each element is True if 1= +Y a b for each corresponding pair of x and y values in the arrays xValues and yValues, otherwise the element is False. Note: You must NOT use for or while in this function. Write a function that begins with the header: def main(): This function calls getNumber three times to get the length of the major axis (a), the length of the minor axis (b), and the number of points along the major axis. The array of x values is created using the linspace function. For example if a = 10.0 and the number of points along the major axis is 6 the array of x values is [0., 2., 4., 6., 8., 10.]. Call yOnEllipse and verifyPoints to create two new arrays. Display the corresponding values of the arrays in three columns under an appropriate heading as shown in the sample output. The main program (not to be confused with the function main) should contain any import statements needed, the definitions of the functions and the statement main(). A sample run of the program is shown on the next page. In the column labeled 'On Ellipse all of the values should be True, why are some of them False? Enter the length of the major axis: Missing input! Enter the length of the major axis: 'hello' hello is not a number! Enter the length of the major axis: stuff Invalid input! Enter the length of the major axis: 10 Enter the length of the minor axis: 5 Enter the number of points along the major axis: 20 X Y On Ellipse 0.00 5.0000000000 True 0.53 4.9930699897 True 1.05 4.9722220073 False 1.58 4.9372797472 False 2.11 4.8879409529 True 2.63 4.8237638894 False 3.16 4.7441464151 False 3.68 4.6482951928 True 4.21 4.5351810367 True 4.74 4.4034738239 True 5.26 4.2514459004 False 5.79 4.0768245750 False 6.32 3.8765578586 True 6.84 3.6464227528 True 7.37 3.3803243628 True 7.89 3.0689220499 True 8.42 2.6965659910 True 8.95 2.2329687827 True 9.47 1.6007269817 True 10.00 0.0000000000 True Programmed by Stew Dent. Date: Fri Jun 8 08:15:38 2018 End of processing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
