Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Python problem! -------------- Show that your code works by running this first test: time = [ 0.0, 2.0, 9.0, 15.0] data = [-0.2, -0.4,
# Python problem!
--------------
Show that your code works by running this first test:
time = [ 0.0, 2.0, 9.0, 15.0] data = [-0.2, -0.4, -0.8, -0.5] t = TimeSeries(time, data) print(t.time, t.data) # should print something
Then, show that your code displays the expected behavior on this second test.
time = [ 0.0, 2.0, 9.0] data = [-0.2, -0.4, -0.8, - 0.5] t = TimeSeries(time, data) # informative ValueError
--------------
# Please use Python!
Part A (10 points) Create a TimeSeries class. This class should have two instance variables. The time instance variable should be able to contain multiple measurements of time, which you may assume to be numeric (i.e. int or float). The data instance variable should be able to contain multiple measurements of some data, which you may also assume to be numeric. The user should be able to pass list s containing the time and data measurements to the TimeSeries class on construction At this stage, the only functionality required of your class is to store the time and data and check that the time and data passed by the user have the same length. If they do not, raise an informative ValueError Show that your code works by running this first test: time = [ 0.0, 2.0, 9.0, 15.0] data = [-0.2, -0.4, -0.8, -0.5] t = TimeSeries (time, data) print(t. time, t. data) # should print something Then, show that your code displays the expected behavior on this second test. time = [ 0.0, 2.0, 9.0] data = (-0.2, -0.4, -0.8, 0.5] = TimeSeries (time, data) t # informative ValueError No Copy/Paste Further parts of this problem will ask you to add to and modify your TimeSeries class. It is not necessary to copy and paste for this. You can and should write the entire TimeSeries class definition, as well as additional supporting code, in the single code cell below. For example, your Part C solution should go in the code cell directly below -- only the code used to test your solution should be shown in Part C. In subsequent parts, you need only write and run test code that demonstrates the correct functioning of your solution. This code will be supplied for you. In [ ]: #your class and supporting code here In [ ]: # first test here In [ ]: # second test here
Step 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