
# example that shows how a function can update a global variable

pi = 3  # sorry --- the checker handles  ints  only  )-:

c = 0

def circ(diameter) :
    """{ pre  diameter >= 0  and  pi >= 3
         post  c == pi * diameter  
    }"""
    global c   # this designates that global c will be updated !
    c = pi * diameter
    
# checker automatically validates the function.

# checker automatically validates that  2 >= 0 and pi >= 3 
# so it lets the call to circ proceed:

novar = circ(2)   # this is a function call that returns no answer

"""{ 1.  c == pi * 2   premise   # postcondition from call to circ(2)
     2.  c_old == 0    premise   # c's value was changed by  circ;
                                 # this is called a _side effect_
    # WE CAN DO MORE STEPS HERE ...
}"""
