Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Python problem. In part (a) we are asked to write a TimeSeries class such that the following codes work. ----------- Show that your code

image text in transcribed

# Python problem.

In part (a) we are asked to write a TimeSeries class such that the following codes work.

-----------

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

------------

This is part (b), which asks us to print something, using the example given:

------------------

Now implement useful printing for your class, allowing the user to easily inspect a TimeSeries object. Demonstrate that the following test works:

t = TimeSeries([0.1, 2.5, 3.8], [0.5, -0.2, 0.2]) print(t)
# printed output An object of class TimeSeries time: [0.1 2.5 3.8] data: [ 0.5 -0.2 0.2] # also acceptable An object of class TimeSeries time: [0.1, 2.5, 3.8] data: [0.5, -0.2, 0.2]

It is not necessary to implement elegant spacing or other cosmetic features, although you are free to do so if you'd like to. Commas in your printed output are acceptable but optional.

----------------------

# Python problem.

Part B (10 points) Now implement useful printing for your class, allowing the user to easily inspect a TimeSeries object. Demonstrate that the following test works: t = TimeSeries ([0.1, 2.5, 3.8], (0.5, -0.2, 0.2]) print(t) # printed output An object of class TimeSeries time: [0.1 2.5 3. 8] data: [ 0.5 -0.2 0.2] # also acceptable An object of class TimeSeries time: [0.1, 2.5, 3. 8] data: [0.5, -0.2, 0.2] It is not necessary to implement elegant spacing or other cosmetic features, although you are free to do so if you'd like to. Commas in your printed output are acceptable but optional. In [ ]: #test here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions