Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use Notepad++ to answer all three questions (Python). For the following crercises, write your code in one text file ending with extension.py. Be sure
Please use Notepad++ to answer all three questions (Python).
For the following crercises, write your code in one text file ending with extension.py. Be sure to use a plain text editor (i.e., NOT Word). I suggest you use Xcode for Mac or Notepad++ for Windows. For parts that require written explanation, use the print function to print your answers to the screen when the script is run, Note that unlike with using the Python interpreter, commands will not print out to the screen automatically when run through a scripting file. Wrap each command you would like to print to the screen in the function print or save the command's output to a variable and then print the variable. Problem 1 (2 pts) Use the sun command described in the lecture notes to find the result for the sum of 1 - 1/2+1/3 - 1/4+1/5-1/6+ ... for several numbers of terms (say 10, 100, 1000). (Hint: read up on the range function online and see how to make it start at 1 instead of 0.) Problem 2 (2 pts) Find the online documentation on the Python math module to familiarize yourself with the functions tised in the problem. Evaluate each of the following using commands from the math module: describe what fune- tions (and constants) you used to get the output (use print): (a) the square of the sine of ; (b) the base 10 logarithm of 100; (c) the absolute value of -4.5: (a) the square root of 16 (can you find two ways to do this with what we've learned so far?) (2 pts) Problem 3 Verify that the following infinite series equals 1/4: 1- 1 5 1 7 3 First, figure out how to represent the pattern using an index n. Then we can generate the list of terms as in the notes. Obviously, we can't really take n to infinity with this series so try letting it go for some large values of n. Note that to complete the problem, you need to compare the answer for increasing numbers of terms (at least 3) in the sum to 7/4 and show that the difference gets smallerStep 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