number1 = raw_input( "Enter numerator: " )number2 = raw_input( "Enter denominator: " )# attempt to convert and divide valuestry: number1 = float( number1 ) number2 = float( number2 ) result = number1 / number2# float raises a ValueError exception except ValueError: print "You must enter two numbers"# division by zero raises a ZeroDivisionError exception except ZeroDivisionError: print "Attempted to divide by zero"# else clause's suite executes if try suite raises no exceptionselse: print "%.3f / %.3f = %.3f" % ( number1, number2, result )
Name (required)
email (will not be published) (required)
Website