Question: Python code for #1,2,&3 please. Markdown cells should be included at the beginning of the notebook and before each exercise, at the minimum. Make sure
Markdown cells should be included at the beginning of the notebook and before each exercise, at the minimum. Make sure that your name and the assignment number is clearly indicated in the first cell of the notebook. Label each exercise in a markdown cell above the exercise. Clearly document each exercise with in-line comments explaining what each line of text does, and with markdown cells explaining what each code block is for. Indicate the names of any other students you got help from on your assignment. Indicate their names in the markdown cell at the beginning of your notebook. You must turn in your own code, it should not be identical to another student's code or something you found on the internet. If you do research and find some help on the internet you should cite that as a reference in you code (as comments or markdown). You will not lose points for this. The purpose of this assignment is to learn about while and for loops. Even if you know about range, xrange, arange, linspace, and similar indexing and interval functions, you may not use them on this assignment 1. Consider (in mathematical notation, not python) the interval (a, b). Suppose you want to divide this interval into n sub-intervals of equal length, (zo-ri), (ri,12), . . . , (z, ) where ro = a and z.-b. For i = 0,1,.. .n, figure out a formula (mathematically) for z, as a function of i, a, b, and n. Write a sequence of python statements that will calculate the value of the n points using a while loop: n= . # you may want to add some other code here while # some test is true # do some stuff to calculate the next x value i, print 1+=1 x Verify that your loop works with the intervals (a,b)-(7,10) (n-3); (12,19.5) (n-10); and (0,2m), n=8. 2. Write a function MakeSubint (a, b,n) that returns a list of the endpoints of the subintervals, e.g, MakeSubint (7,10, 3) should return the list (7,8,9,101 Verify that your function works with the same data used in the previous exercise. Use a while loop. Verify with the same data as in ex. 1. 3. Write a function MakeSubintF (a, b,n) as in the previous exercise, this time using a for loop. Verify it with the same data
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
