#---------------------------------------------------------------------- # (C) Monday, January 29, 2018 -- Dr. William T. Verts # # This second version checks each number to enforce that it is either # 0 or positive. The problem with this version is that the code to # check values is essentially the same in each case. We've written # the same code twice. #---------------------------------------------------------------------- N1 = input("Enter Number #1 --- ") while (N1 < 0): print "This is not a positive number" N1 = input("Enter Number #1 --- ") N2 = input("Enter Number #2 --- ") while (N2 < 0): print "This is not a positive number" N2 = input("Enter Number #2 --- ") A = (N1 + N2) / 2.0 print "The average is: ", A