Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2 -- Writing a function DEFINITION and showing a TABLE: The starter code includes statements that demonstrate how to use math.pi, math.sin() and math.cos().
Part 2 -- Writing a function DEFINITION and showing a TABLE:
- The starter code includes statements that demonstrate how to use math.pi, math.sin() and math.cos(). You will need these tools for this part of the lab exercise.
- In a math class you may have learned the following identity: sin2(n) + cos2(n) = 1 for any number 'n' (i.e. "the sin squared plus the cosine squared is equal to one"). In the same file you used for Part 1 above, write code that demonstrates this identity: Write a function definition that takes one parameter named 'intervals', the number of intervals to appear in a table of numbers. The function should print a table with (count+1) rows, showing a sequence of numbers beginning with 0 and ending with 2pi. Each row should also show sin(n), cos(n) and sin2(n) + cos2(n).
- Test your function using the statements provided in the sample code's "main" function (you will need to un-comment the statements when you are ready to use them). Here are the same statements for reference: show_sin_cos_squared_table(8) show_sin_cos_squared_table(20) Here is what the output should look like. Notice when the function is called with the argument 8, the resulting table has 9 rows, with the lowest value of 'n' equal to 0, the highest value (last row) equal to 2pi, and equal steps in the values of 'n'. You can see some representational error in the second table. Notice that the numbers in the last column of the table have 17 digits after the decimal point.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started