In [5]:
a=list(range(1,101))
b=list(range(100,0,-1))
In [7]:
c=sum(a+b)
In [12]:
c
Out[12]:
In [13]:
a.append(99)
In [15]:
d=sum(a+b)
In [16]:
d
Out[16]:
In [17]:
object
Out[17]:
In [20]:
a = list([1, 2, 3])
a
Out[20]:
In [21]:
a = list()
a
Out[21]:
In [250]:
class User:
def __init__(self, firstname, lastname, email, password, gender, age, can_like = True):
self.ID = uuid.uuid4()
self.firstname = firstname
self.lastname = lastname
self.email = email
self.password = password
self.gender = gender
self.age = age
self.can_like = can_like
self.status = 'single'
def change_relationship_status(self, status):
self.status = status
@staticmethod
def create_user(firstname, lastname, email, password, gender, age, can_like = True):
user = User(firstname, lastname, email, password, gender, age, can_like)
return user
class Account:
def __init__(self, user):
self.user = user
In [251]:
user1 = User('Nelson', 'Agera', 'nelsonagera@gmail.com', '12345', 'Male', 27)
user2 = User('Achilles', 'Rasquinha', 'abc@xyz.com', '12345', 'Male', 21)
In [252]:
users = [ ]
accnt = [ ]
In [253]:
users.append(user1)
users.append(user2)
In [254]:
account1 = Account(users[0])
In [255]:
print(user1.status)
user1.change_relationship_status('married')
print(user1.status)
In [256]:
u = User.create_user('Achilles', 'Rasquinha', 'abc@xyz.com', '12345', 'Male', 22)
In [257]:
user2.age
Out[257]:
In [258]:
u.age
Out[258]:
In [ ]:
In [272]:
class Phone:
def __init__(self,colour,displayResolution,noOfButtons=12):
self.noOfButtons=noOfButtons
self.colour =colour
self.displayResolution=displayResolution
def setcolour(self,newColour):
self.colour=newColour
@staticmethod
def hasAntenna():
return True
In [273]:
phone1=Phone('Black',[720, 1020])
In [274]:
phone1.colour
Out[274]:
In [275]:
phone1.setcolour('Blue')
In [276]:
phone1.colour
Out[276]:
In [278]:
phone1.hasAntenna()
Out[278]:
In [279]:
Phone.hasAntenna()
Out[279]:
In [280]:
class CustomObject(object):
pass
In [339]:
class Gadget(Device):
pass
class Device(object):
GLOBAL_ID_COUNTER = 0
def __init__(self, resolution):
self.resolution = resolution
def set_resolution(self, resolution):
self.resolution = [sum(resolution), sum(resolution)]
class Phone(Device, Gadget):
def __init__(self, resolution):
super(Phone, self).__init__(resolution)
@staticmethod
def set_resolution(self, resolution):
super(Phone, self).set_resolution(resolution)
print(self.resolution)
self.resolution = self.resolution + self.resolution
class Screen(Device):
def __init__(self, resolution):
super(Screen, self).__init__(resolution)
In [340]:
screen = Screen([720, 190])
screen.GLOBAL_ID_COUNTER
Out[340]:
In [341]:
screen.resolution
Out[341]:
In [342]:
phone = Phone([320, 480])
phone.resolution
phone.set_resolution([120, 120])
phone.resolution
In [300]:
device = Device([120, 480])
device.resolution
Out[300]:
In [328]:
# type.__name__
type, set, dict, list, range, int, str
Out[328]:
In [ ]: