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

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
Image of page 1

Subscribe to view the full document.

Image of page 2
You've reached the end of this preview.
  • Fall '11
  • Birnbaum
  • Addition, nonnegative integer

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern