<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Resources
Errors & Exceptions in Python
Step1:  Raising errors
Anticipate and catch errors
Raise a more informative error than the default error
Example
Step2:  Raising warnings
Example
<ASSISTANT_TASK:>
Python Code:
def check_python_version():
    print 'Python version:\n', sys.version
    assert sys.version_info < (3,0)
check_python_version()
def improved_check_python_version():
    print 'Python version:\n', sys.version
    try:
        assert sys.version_info < (3,0)
    except:        
        raise AssertionError('Incompatible version of Python: use Python version < 3.0')
improved_check_python_version()
Explanation: Resources
Errors & Exceptions in Python:
 https://docs.python.org/3/tutorial/errors.html
Built-In Excpetions in Python:
 https://docs.python.org/2/library/exceptions.html
Numpy Testing:
 http://docs.scipy.org/doc/numpy/reference/routines.testing.html
Assert statements
Example: Assert that a specific version of Python is being used
End of explanation
def test_type_float(var):
    if not isinstance(var, float):
        raise TypeError('Expected input type == float')
f = 1.
# Since the input type is a float, no error is raised.
test_type_float(f)
i = 1
# Since the input type is a list, an error is raised.
test_type_float(i)
def incorrect_divide_by_two(var):
    return var / 2
print incorrect_divide_by_two(f)
print incorrect_divide_by_two(i)
def correct_divide_by_two(var):
    '''
    Divides input by two.
    
    INPUT
    var : float
    '''
    test_type_float(var)
    return var / 2
correct_divide_by_two?
print correct_divide_by_two(f)
print correct_divide_by_two(i)
Explanation: Raising errors
Anticipate and catch errors
Raise a more informative error than the default error
Example: Division in Python versions < 3.0
End of explanation
def divide_by_two(var):
    if isinstance(var, int):
        warnings.warn('Performing floor division. Input type == int', Warning)
    return var / 2
divide_by_two(1)
divide_by_two(np.array([1]))
def divide_by_two(var):
    if isinstance(var, int):
        warnings.warn('Performing floor division. Input type == int', Warning)
    if isinstance(var, np.ndarray):
        if var.dtype == int:
            warnings.warn('Performing floor division. numpy.dtype == int', Warning)
    return var / 2
divide_by_two(np.array([1]))
Explanation: Raising warnings
Example: Division in Python versions < 3.0
End of explanation
<END_TASK>