class Zillion: def __init__(self,digits): self.digits = digits try: int(digits) except ValueError: raise RuntimeError # for n in range (0,len(str(digits))): # test[n]=str(digits)[n] def increment(self): return 1 def isZero(self): for n in range (0,len(str(digits))): if digits[n] is not 0: return False return True def toString(self): return str(self) # # TESTS. Test the class Zillion for CSci 1913 Lab 2. # # James Moen # 18 Sep 17 # # Every test is followed by a comment which shows what must be printed if your # code works correctly. It also shows how many points the test is worth. # try: z = Zillion('') except RuntimeError: print('Empty string') # It must print 'Empty string' without apostrophes. 2 points. try: z = Zillion(' , ') except RuntimeError: print('No digits in the string') # It must print 'No digits in the string' without apostrophes. 2 points. try: z = Zillion('1+0') except RuntimeError: print('Non-digit in the string') # It must print 'Non-digit in the string' without apostrophes. 2 points. try: z = Zillion('0') except RuntimeError: print('This must not be printed') # It must print nothing. 2 points. print(z.isZero()) # It must print True. 2 points. try: z = Zillion('000000000') except RuntimeError: print('This must not be printed') # It must print nothing. 2 points. print(z.isZero()) # It must print True. 2 points. try: z = Zillion('000 000 000') except RuntimeError: print('This must not be printed') # It must print nothing. 2 points. print(z.isZero()) # It must print True. 2 points. try: z = Zillion('997') except RuntimeError: print('This must not be printed') # It must print nothing. 2 points. print(z.isZero()) # It must print False. 2 points. print(z.toString()) # It must print 997. 2 points. z.increment() print(z.toString()) # It must print 998. 2 points. z.increment() print(z.toString()) # It must print 999. 2 points. z.increment() print(z.toString()) # It must print 1000. 2 points. try: z = Zillion('0 9,9 9') except: print('This must not be printed') # It must print nothing. 3 points. z.increment() print(z.toString()) # It must print 1000. 2 points.