In [2]:
assert True, "This is an assert statement"

In [3]:
num = 2.003

In [4]:
assert num > 2, "Value must be > 2"

In [5]:
assert num < 2.001, "Value must be less than 2.001"


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-5-857f7c04dfdf> in <module>()
----> 1 assert num < 2.001, "Value must be less than 2.001"

AssertionError: Value must be less than 2.001

In [8]:
def temp_c_to_k(temp_in_c):
    '''Converts temperature from celsius to kelvin.
    '''
    assert temp_in_c > -273.15, "Cannot have celsius below absolute zero!"
    temp_in_k = temp_in_c + 273.15
    assert temp_in_k > 0, "Cannot have negative Kelvin temperatures"
    return temp_in_k

In [10]:
print(temp_c_to_k(-1230))


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-10-2a430c3381f5> in <module>()
----> 1 print(temp_c_to_k(-1230))

<ipython-input-8-84c10e191fbc> in temp_c_to_k(temp_in_c)
      2     '''Converts temperature from celsius to kelvin.
      3     '''
----> 4     assert temp_in_c > -273.15, "Cannot have celsius below absolute zero!"
      5     temp_in_k = temp_in_c + 273.15
      6     assert temp_in_k > 0, "Cannot have negative Kelvin temperatures"

AssertionError: Cannot have celsius below absolute zero!

In [11]:
help(temp_c_to_k
    )


Help on function temp_c_to_k in module __main__:

temp_c_to_k(temp_in_c)
    Converts temperature from celsius to kelvin.


In [ ]: