Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Poly:
- def __init__(self, list):
- if Poly.validate_input(list):
- self.list = list
- else:
- raise Exception("Invalid input")
- @staticmethod
- def validate_input(args):
- """Check if the argument is a nonempty list of numbers"""
- if args and isinstance(args, list) and all([isinstance(arg, int) or isinstance(arg, float) for arg in args]):
- return True
- else:
- return False
- def order(self):
- """Return the order of the polynomial."""
- if self.list != [0]:
- return len(self.list) - 1
- else:
- raise Exception("Zero polynomial.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement