Python
Python
def PrintInfo(self):
print(self.telephoneType, self.brand)
for x in self.memory.items():
print(" ".join(x))
@staticmethod
def CallICE():
print("Method is not implemented")
------------------------------------------------------------------------------
class Mobile(Telephone):
def __init__(self, brand, simCards, activeSimCard):
self.brand = brand
self.simCards = simCards if len(simCards) < 3 else simCards[:2]
self.activeSimCard = self.simCards[activeSimCard]
self.telephoneType = "Mobile"
self.id = random.randint(0,1000000)
self.memory = {}
def HasProductDefect(self):
if self.brand == "XYZBadBrand" and self.id % 333 == 0:
print("This mobile HAS product defect")
elif self.brand != "XYZBadBrand" and self.id % 999 == 0:
print("This mobile HAS product defect")
else:
print("This mobile HAS NO product defect")
def CallICE(self):
if len(self.memory) == 0:
print("There's no number in memory!")
else:
first_person = sorted(self.memory, key=lambda x: x)
print(first_person[0], self.memory[first_person[0]], self.activeSimCard)
def concatenate_string(string1, string2):
s = ""
for x in range(len(string1)):
s += string1[x]
s += string2[x]
return s
def pascal_triangle(num):
if num == 0:
return []
elif num == 1:
return [[1]]
else:
nrow = [1]
res = pascal_triangle(num-1)
lrow = res[-1]
for x in range(len(lrow)-1):
nrow.append(lrow[x] + lrow[x+1])
nrow += [1]
res.append(nrow)
return res