def SquareRoot (N):
Guess = N / 2.0
Quotient = N / Guess
NewGuess = (Guess + Quotient) / 2.0
while (abs(Guess - NewGuess) > 1.0e-15):
#print (Guess, NewGuess)
Guess = NewGuess
Quotient = N / Guess
NewGuess = (Guess + Quotient) / 2.0
return NewGuess
def Distance (X1,Y1,X2=0,Y2=0): # Note that X2 and Y2 now have default values
A = X2 - X1
B = Y2 - Y1
return SquareRoot(A*A + B*B)
print (Distance(3,4,9,12)) # Distance between points <3,4> and <9,12>
print (Distance(3,4)) # Distance between points <3,4> and <0,0>
def Taxes (Gross=50000,Children=0,TaxRate=0.05):
return Gross * TaxRate / (Children+1)
print (Taxes(65000,3,0.06)) # Filling in all three parameters
print (Taxes(65000,3)) # Filling in first two, third uses default
print (Taxes(65000)) # Filling in first, second two use defaults
print (Taxes()) # All three parameters use default values