#assignment instructions create 2 test cases that will trap the errors
# This program is a code of Functions for addition, subtraction, multiplication, and division def Add(): print (var1+var2) def Subtract(): print (var1-var2) def Multiply(): print (var1*var2) def Divide(): print (var1/var2) def main(): print("Welcome to my calculator") # The exception below restarts the program if user doesn't enter an interger instead of showing an error. try: range1 = int(input('Enter Low Range:')) range2 = int(input('Enter High Range:')) var1 = int(input('Enter Your First Number: ')) var2 = int(input('Enter Your Second Number: ')) except ValueError: print("Please enter intergers only, re-enter.") main() if var1 < range1 or var2 > range2 or var1 > range2 or var2 < range1: print("Your number is not within the correct range, please try agian") else: print('{} + {} = '.format(var1, var2)) print(var1 + var2) print('{} - {} = '.format(var1, var2)) print(var1 - var2) print('{} * {} = '.format(var1, var2)) print(var1 * var2) #This is an exception to entering "0". By doing so, we will no longer get an error and get to restart the program. try: print('{} / {} = '.format(var1, var2)) print(var1 / var2) except ZeroDivisionError: print("Zero is not allowed") again = input("Would you like to calculate again? y/n") if again == "y" or \ again == "Y": main() else: print("Thanks for using my calculator!") again = input("Would you like to calculate again? y/n") if again == "y" or \ again == "Y": main() else: print("Thanks for using my calculator!") main() #These are my ranges x=0 y=1000 def IsinRange(number): if x <= number <= y: print('The number {} is in range ({}, {})'.format(number, x, y)) else: print('The number {} is not in range ({}, {})'.format(number, x, y)) testNumbers = [int(input("Enter any number!:"))] for a in testNumbers: IsinRange(a)