Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1.  
  2. def expression_matter(a, b, c):
  3.  
  4.     # ensuring we have the right input // error handling
  5.     if not isinstance(a, int) or not isinstance(b, int) or not isinstance(c,int):
  6.         raise TypeError("sorry, only intergers allowed - try again")
  7.     if not a >= 1 or not a <= 10:
  8.         raise ValueError("sorry, a needs to be between 1 and 10")
  9.     if not b >= 1 or not b <= 10:
  10.         raise ValueError("sorry, b needs to be between 1 and 10")
  11.     if not c >= 1 or not c <= 10:
  12.         raise ValueError("sorry, c needs to be between 1 and 10")
  13.  
  14.     #list of possible calculations
  15.     calc1 = a * (b + c)
  16.     calc2  = a * b * c
  17.     calc3 = a + b * c
  18.     calc4 = (a + b) * c
  19.     calc5 = a + b + c
  20.    
  21.     # highest achievable result
  22.     return max(calc1,calc2,calc3,calc4,calc5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement