SEP-PYTHON

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 . . .

7. Create array using NumPy and perform array operations

 
  
 # 7.Write a Program to Demonstrate exception handling
 #---------------------------------
 
def divide_numbers():
    try:
        # Code that might cause an error
        num1 = int(input("Enter numerator: "))
        num2 = int(input("Enter denominator: "))
        
        result = num1 / num2
        
    except ValueError:
       
        print("Error: Invalid input! Please enter numeric values.")
        
    except ZeroDivisionError:
       
        print("Error: You cannot divide by zero.")
        
    except Exception as e:
        
        print(f"An unexpected error occurred: {e}")
        
    else:
       
        print(f"Success! The result is: {result}")
        
    finally:
       
        print("Execution complete. Cleaning up resources...")
 
divide_numbers()