# The four loops in the previous version have been factored # out into a general function for entering positive numbers. # Parameter Message will be passed the string specific to the # desired value. def Distance(X1,Y1,X2,Y2): DeltaX = X2 - X1 DeltaY = Y2 - Y1 return sqrt(DeltaX*DeltaX + DeltaY*DeltaY) def GetAPositive (Message): N = input(Message) while (N < 0): print "This value is bogus" N = input(Message) return N def Main(): A1 = GetAPositive("Enter X1 --- ") B1 = GetAPositive("Enter Y1 --- ") A2 = GetAPositive("Enter X2 --- ") B2 = GetAPositive("Enter Y2 --- ") print Distance(A1,B1,A2,B2) return