Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note: The sample solution is on the last page Note: The sample solution is on this page The purpose of this question is to write

image text in transcribedNote: The sample solution is on the last page
image text in transcribed
image text in transcribedNote: The sample solution is on this page
The purpose of this question is to write a complete python program that creates and displays a table of polar and Cartesian coordinates for a spiral. An example of a spiral is shown below. 200 Spiral -100 -130 -100 50 50 00 150 200 Write a function that begins with the following header. def computeCoordinatesf(intervals, maxAngle, scale): where intervals is the number of equally spaced angles, maxAngle is the maximum angle for the spiral, and scale is the scale factor for the spiral. The larger maxAngle is, the more revolutions in the spiral. The larger scale is, the farther apart are the lines of the spiral. Create a list of equally spaced angles from 0 to maxAngle radians. Create a list of radii. Use the formula radius scale x angle to compute each radius from the corresponding angle. Add the radius to the list of radii. The lists of angles and radii are the polar coordinates of the points in the spiral. Using the polar coordinates, create lists of the corresponding X and Y coordinates (Cartesian coordinates) of the points on the spiral. Use the formula x = radius x cos(angle) to compute each X coordinate from the corresponding radius and angle. Add each X coordinate to the list of X coordinates. Use the formula y radius x sin(angle) to compute each Y coordinate from the corresponding radius and angle. Add each Y coordinate to the list of Y coordinates. Return the lists of angles, radii, X coordinates and Y coordinates in that order. Write a function that begins with the following header. def displayCoordinates(angles, radii, xCoords, yCoords): This function is given the lists of angles, radii, X coordinates and Y coordinates of the points in the spiral. Display the angle, radius, X coordinate and Y coordinate of each point in the spiral with the coordinates for one point per line of output. See the sample run of the program for the format of the output. Display each angle and radius to 4 decimal places in 10 character positions. Display each X and Y coordinate to 6 decimal places in 14 character positions. Separate each value in a line of output from the next value by one space. Display the two lines of headings so that the text is positioned as shown in the sample run of the program Write a function that begins with the following header. def main0: Input the number of intervals as an integer Loop as long as the number of intervals is greater than zero: input the maximum angle as a float, if the angle is less than or equal to zero display an error message that includes the value of the angle as shown in the sample run of the program, otherwise continue input the scale factor as a float, if the scale factor is less than or equal to zero display an error message that includes the value of the scale factor as shown in the sample run of the program, otherwise continue call computeCoordinates to get the lists of angles, radi X coordinates and Y coordinates call displayCoordinates to display the lists of angles, radii, X coordinates and Y coordinates input the number of intervals as an integer Call displayTerminationMessage to display the termination message. The main program (not to be confused with function named main) should contain the function definitions, any import statements needed by the functions and a call to the function named main. A sample run of the program is shown on the next page. Enter the number of intervals: 10 Enter the maximum angle in radians: The maximum angle, 8, must be greater than zero. Enter the number of intervals: 10 Enter the maximum angle in radians: 6.28 Enter the scale factor for the spiral: e The scale factor, e, must be greater than zero. Enter the number of intervals: 20 Enter the maximum angle in radians: 6.28 Enter the scale factor for the spiral: 2.5 Polar Coordinates Cartesian Coordinates Radius 0.8000 0.7850 1.5700 2.3550 3.1400 x coordinate 0.000008 0.746618 1.270451 1.385144 0.972216 0.003126 -1.451189 -3.224922 Y coordinate e.000000 0. 242459 0.922418 1.904573 2.985699 3.924999 4.480865 4.449146 3.697762 2.192834 0.012502 -2.653970 5.522362 -8.243581 -10.444513 -11.774966 -11.955121 10.817530 -8.338143 -4.651892 0.050009 , 0000 0.3140 0.6280 0.9420 1.2560 1.5700 1.8848 2.1980 4.7100 5.4950 6.2800 7.9656 7.8500 8.6350 9.4200 5.075919 -6.716078 7.849999 -8.217035 -7.631588 2.8260 3.1400 3.4540 3.7680 4.0820 4.3960 4.7100 5.0240 5.3380 5.6520 5.9660 6.2800 Enter the number of intervals: 10.2e5e 6.015429 10.9900 11.7750 .2813e 12.5600 3.850801 13.3458 14.1388 14.9152 14.170996 15.7000 15.699920 3.419394 7.814734 11.407553 Programmed by Stew Dent. Date: Sat Jan 12 21:07:21 2019 End of processing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions