document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. class Bin:
  2.     def __init__(self, digit):
  3.         """init the digit value and create list"""
  4.         if digit < 0 or digit > 9:
  5.             raise ValueError("digit must be >= 0 and <=9")
  6.        
  7.         if not isinstance(digit, int):
  8.             raise ValueError("digit must be an integer")
  9.        
  10.         self.digit = abs(digit)
  11.         self.list = []
  12.        
  13.     def get_bin(self):
  14.         """return the bin as a list"""
  15.         return self.list
  16.    
  17.     def get_digit(self):
  18.         """return the digit value of the object"""
  19.         return self.digit
  20.    
  21.     def insert(self, new):
  22.         """insert element in the 0th position"""
  23.         self.list.append(new)
  24.        
  25.     def clear(self):
  26.         """clear the list"""
  27.         self.list.clear()
');