hw2pr1.py

# hw2pr1.py - Mallika Patel hw2pr1.py done in lab def...

• Homework Help
• 2

This preview shows 1 out of 2 pages.

# April 17, 2018 # Mallika Patel # hw2pr1.py -- done in lab def fracSteps(N): """input: nonnegative integer N output: list of N evenly spaced floating-point values starting at 0.0 and going up to, but not including 1.0 """ LC = [x/N for x in range(N)] return LC def steps(low,hi,N): """input: two numbers low and hi and a nonnegative integer N output: regularly-spaced list of N floats starting at low and going up to, but not including, hi itself """ LC = [((hi-low)*x + low) for x in fracSteps(N) ] return LC def dbl_steps(low,hi,N): """input: two numbers low and hi and a nonnegative integer N output: double each of the values in the list that the steps function creates """ LC = [2*x for x in steps(low,hi,N)] return LC from csplot import * from math import * def fsteps(f,low,hi,N): """input: a function f, two numbers low and hi, and a nonnegative integer N output: the function f evaluated at each point """ LC = [f(x) for x in steps(low,hi,N)] return LC def dbl(x): """ input: a number x (int or float) output: twice the input """ return 2*x def sq(x): """input: a number x (int or float) output: square of x """ return x**2 def finteg(f,low,hi,N): """ input: function f with lower limit low and upper limit hi where N steps

Subscribe to view the full document.

You've reached the end of this preview.
• Fall '11
• Birnbaum

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern