Advertisement
Guest User

rectangeData allowing float

a guest
Oct 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. from Rectangle import rectangle as r
  2. from string import digits as nums
  3. # class NotANumberError(Exception):
  4. #     def __init__(self):
  5. #         print('Invalid input, only integer values are allowed')
  6.  
  7. # class NotAZero(Exception):
  8. #     def __init__(self):
  9. #         print("Invalid input, value shoudn't be a zero.")
  10.  
  11. # class BeginsWithZero(Exception):
  12. #     def __init__(self):
  13. #         print("Invalid input, value shoudn't begin with a zero.")
  14.  
  15. def main():
  16.     rectangle.area()
  17.     rectangle.perimeter()
  18.     rectangle.hypotenuse()
  19.     print(f'{rectangle}\nRectangle area is {rectangle.area()}, perimeter is {rectangle.perimeter()} and hypotenuse is {round(rectangle.hypotenuse(), 2)}')
  20.  
  21.  
  22. if __name__ == "__main__":
  23.     while True:
  24.         try:
  25.             askL = float(input('Please provide rectangle length: '))
  26.             #if askL[0] == '0':
  27.             #    raise BeginsWithZero
  28.             #for item in askL:
  29.             #    if item not in nums:
  30.             #        raise NotANumberError
  31.  
  32.             askW = float(input('Please provide rectangle width: '))
  33.             #if askW[0] == '0':
  34.             #    raise BeginsWithZero
  35.             #for item in askW:
  36.             #    if item not in nums:
  37.             #        raise NotANumberError
  38.         except:
  39.             print('Invalid input, please, try again.')
  40.        
  41.         else:
  42.             rectangle = r.rectangle(askL,askW)
  43.             break
  44.  
  45.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement