2.4. Type None

2.4.1. Definition

  • First letter capitalized, other are lower cased

  • Empty (null) or unknown (unset) value

  • It is not False value

  • With if statements behaves like negative values

    >>> data = None
    

2.4.2. Comparison

  • Do not use == or != to check None values

  • x is None - x is the same object as y

  • x is not None - x is not the same object as y

    >>> age = None
    >>>
    >>> age == None
    True
    >>> age != None
    False
    
    >>> age = None
    >>>
    >>> age is None
    True
    >>> age is not None
    False
    

2.4.3. Assignments

Code 2.19. Solution
"""
* Assignment: Type None
* Complexity: easy
* Lines of code: 5 lines
* Time: 3 min

English:
    1. Use data from "Given" section (see below)
    2. What you need to put in expressions to get the expected outcome?
    3. Compare result with "Tests" section (see below)

Polish:
    1. Użyj danych z sekcji "Given" (patrz poniżej)
    2. Co należy podstawić w wyrażeniach aby otrzymać wartość oczekiwaną?
    3. Porównaj wyniki z sekcją "Tests" (patrz poniżej)

Tests:
    >>> bool(a)
    True
    >>> bool(b)
    False
    >>> bool(c)
    True
    >>> bool(d)
    False
    >>> bool(e)
    False
"""


# Given
a = ... is None
b = ... is not None
c = bool(bool(...) is not bool(...)) == False
d = (bool(bool(...) is not bool(...)) == False and bool(...))
e = (bool(bool(...) is not bool(...)) == False and bool(...)) and (... is not None)