1a           Write a function COTlistRange(xstart,xend,xstep) that returns a list that has:                - as index 0 item, the value...

80.2K

Verified Solution

Question

Programming

1a          Write a function COTlistRange(xstart,xend,xstep) that returns alist that has:

              - as index 0 item, the value of xstart

              - as index 1 item, the value xstart+xstep

              - as index 2 item, the value (xstart+xstep)+xstep,

              and so on as long as the value does equal or pass the value ofxend.

              However, the function should return an empty string if for positivexstep, xstart>xend or if for negative xstep, xstart < xend.Here are three examples:

                       a = COTlistRange(2, 3.51, 0.5) should produce

                       a = [2, 2.5, 3., 3.5]

                       a = COTlistRange(2, 0.01, -0.5) should produce

                       a = [2, 1.5, 1., 0.5]      

                       a = COTlistRange(2, 1.51, 0.5) should produce

                       a = []   

              Your code should also have a function mainProg() for testing theCOTlistRange(xstart,xend,xstep) function and the associated if__name__ == statement. Write the mainProg() code so that it doesthe three examples shown above.

b            \"Walk\" your code of part a for the three examples, i.e. create acolumn for each variable showing in the column the evolution ofchanging object values.

c            Repeat part a with a function COTtupleRange(xstart,xend,xstep). Youare not allowed to use the tuple command to convert your resultfrom part a to a tuple.

Answer & Explanation Solved by verified expert
4.2 Ratings (824 Votes)
The above code has been    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students