Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Rectangle import rectangle as r
- from string import digits as nums
- # class NotANumberError(Exception):
- # def __init__(self):
- # print('Invalid input, only integer values are allowed')
- # class NotAZero(Exception):
- # def __init__(self):
- # print("Invalid input, value shoudn't be a zero.")
- # class BeginsWithZero(Exception):
- # def __init__(self):
- # print("Invalid input, value shoudn't begin with a zero.")
- def main():
- rectangle.area()
- rectangle.perimeter()
- rectangle.hypotenuse()
- print(f'{rectangle}\nRectangle area is {rectangle.area()}, perimeter is {rectangle.perimeter()} and hypotenuse is {round(rectangle.hypotenuse(), 2)}')
- if __name__ == "__main__":
- while True:
- try:
- askL = float(input('Please provide rectangle length: '))
- #if askL[0] == '0':
- # raise BeginsWithZero
- #for item in askL:
- # if item not in nums:
- # raise NotANumberError
- askW = float(input('Please provide rectangle width: '))
- #if askW[0] == '0':
- # raise BeginsWithZero
- #for item in askW:
- # if item not in nums:
- # raise NotANumberError
- except:
- print('Invalid input, please, try again.')
- else:
- rectangle = r.rectangle(askL,askW)
- break
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement