String classification

Save all these functions in file classify.py

  1. Write function class1() that, given a text (str), returns True if it contains only lowercase letters and False otherwise. Examples:

    >>> class1('Hi John')
    False
    >>> class1('three cars')
    False
    >>> class1('diamond')
    True
    >>> class1('CLUE')
    False
    >>> class1('sweter')
    True
    

    Note

    More tests are provided in file test-class1.txt

  2. Write function class2() that, given a text (str), returns True if it represents a real amount and False otherwise. Examples:

    >>> class2('Bye. Alex')
    False
    >>> class2('0.0')
    True
    >>> class2('34.53€')
    False
    >>> class2('123.0')
    True
    >>> class2('Price: 45.8')
    False
    >>> class2('8723.6512')
    True
    >>> class2('234567')
    False
    >>> class2('0.')
    True
    

    Note

    More tests are provided in file test-class2.txt

Solution

A solution is provided in file classify.py.