Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. class IntList(list):
  2.     def append(self,elem):
  3.         if type(elem) is int:
  4.             super().append(elem)
  5.     pass
  6.  
  7.     def positive_sum(self):
  8.         S=0
  9.         for i in(self):
  10.             if i>0:
  11.                 S+=i
  12.         return S
  13.  
  14.     def negative_sum(self):
  15.         S = 0
  16.         for i in (self):
  17.             if i < 0:
  18.                 S += i
  19.         return S
  20.  
  21.     def insert(self,ind,elem):
  22.         if type(elem) is int:
  23.             super()[ind]=elem
  24.         pass
  25.  
  26.     def extend(self,elem):
  27.         if type(elem) is int:
  28.             super().append(elem)
  29.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement