(Solved) : Restrictions T Import Anything Use Built Functions Types Methods Like Class Outlet Represe Q42782365 . . .

Restrictions: • you cant import anything. • You can use all the built-in functions and types and their methods) as you like!class Outlet: Represents an electrical outlet (the thing you plug devices into to get electricity). It might have some Device

Please solve in python! thank you

Restrictions: • you can’t import anything. • You can use all the built-in functions and types and their methods) as you like! class Outlet: Represents an electrical outlet (the thing you plug devices into to get electricity). It might have some Devices plugged into it, which may be on or not. • def __init__(self, devices=None): ensures there’s a field named devices for this object. Uses the provided value; but if devices=None, a new empty list is created as the value. def _str_(self): returns a str that follows this pattern. Note, you should try to use the str definition from Devices here (that’s the learning goal). “Outlet([(+100W: lightbulbi), (+ow: blender)])” def repr_(self): returns a str that follows this pattern. Note, you should try to use the repr definition from Devices here (that’s the learning goal) “Outlet([Device(‘lightbulbi’, 100, True), Device(“blender’, 200, False)])” defeq_(self,other): both parameters are Outlets. returns True when they have identical values for their field, False otherwise. (overrides the meaning of = for Outlets!) def max_watts(self): returns the maximum watts on this outlet if all devices are on. def watts_now(self): returns the actual watts being used by this outlet at the moment. • def add_device(self, device): adds the given device to the end of the devices list. • def remove_device(self, name): finds and removes the (first) device with the indicated name. (a string, not the whole Device object). Returns the device if found, or None when no device of that name was found. • def turn_off_all(self): ensures that all devices on this outlet are turned off. Show transcribed image text Restrictions: • you can’t import anything. • You can use all the built-in functions and types and their methods) as you like!
class Outlet: Represents an electrical outlet (the thing you plug devices into to get electricity). It might have some Devices plugged into it, which may be on or not. • def __init__(self, devices=None): ensures there’s a field named devices for this object. Uses the provided value; but if devices=None, a new empty list is created as the value. def _str_(self): returns a str that follows this pattern. Note, you should try to use the str definition from Devices here (that’s the learning goal). “Outlet([(+100W: lightbulbi), (+ow: blender)])” def repr_(self): returns a str that follows this pattern. Note, you should try to use the repr definition from Devices here (that’s the learning goal) “Outlet([Device(‘lightbulbi’, 100, True), Device(“blender’, 200, False)])” defeq_(self,other): both parameters are Outlets. returns True when they have identical values for their field, False otherwise. (overrides the meaning of = for Outlets!) def max_watts(self): returns the maximum watts on this outlet if all devices are on. def watts_now(self): returns the actual watts being used by this outlet at the moment. • def add_device(self, device): adds the given device to the end of the devices list. • def remove_device(self, name): finds and removes the (first) device with the indicated name. (a string, not the whole Device object). Returns the device if found, or None when no device of that name was found. • def turn_off_all(self): ensures that all devices on this outlet are turned off.

Expert Answer


Answer to Restrictions: • you can’t import anything. • You can use all the built-in functions and types and their methods) as …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us