Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def expression_matter(a, b, c):
- # ensuring we have the right input // error handling
- if not isinstance(a, int) or not isinstance(b, int) or not isinstance(c,int):
- raise TypeError("sorry, only intergers allowed - try again")
- if not a >= 1 or not a <= 10:
- raise ValueError("sorry, a needs to be between 1 and 10")
- if not b >= 1 or not b <= 10:
- raise ValueError("sorry, b needs to be between 1 and 10")
- if not c >= 1 or not c <= 10:
- raise ValueError("sorry, c needs to be between 1 and 10")
- #list of possible calculations
- calc1 = a * (b + c)
- calc2 = a * b * c
- calc3 = a + b * c
- calc4 = (a + b) * c
- calc5 = a + b + c
- # highest achievable result
- return max(calc1,calc2,calc3,calc4,calc5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement