Question: Exercise 1b) Implement the decay parameter as a property 1p Turn the decay parameter a into a property. Implement a setter method that throws

Exercise 1b) Implement the decay parameter as a property 1p Turn the decay parameter a into a property.

Exercise 1b) Implement the decay parameter as a property 1p Turn the decay parameter a into a property. Implement a setter method that throws a ValueError if the provided value is negative. Use this setter method in the constructor and write a test function test negative_decay_raises_ValueError that verifies that the following code raises a ValueError: model ExponentialDecay (0.4) model.decay = -1.0 Hint - writing properties with private variables You can read about properties with getters and setters in the lecture notes on properties or in the slides on classes in Python.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

class ExponentialDecay def initself value Constructor that takes an argument for decay para... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!