Creating a Network of Computers
Now, you'll overload the +
operator to create a Network
of devices when two Computer
s are added. The following class has already been defined for you:
class Network:
def __init__(self, ip_addresses):
self.ip_addresses = ip_addresses
Here, ip_addresses
is a list of IP addresses, each a string of numbers and dots.
Cet exercice fait partie du cours
Intermediate Object-Oriented Programming in Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
class Computer:
# __init__() should define operating_system and ip_address
# as instance-level attributes
def __init__(self, ____, ____):
self.____ = operating_system
self.ip_address = ____