4. None

4.1. Defining None

  • First letter capitalized, other are lower cased

  • Empty value (null)

  • Used for unknown (unset) values

  • It is not False value

  • With if statements behaves like negative values

my_var = None

4.2. Logic operators

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

Table 4.2. Logic operators

Operand

Description

x is None

x is the same object as y

x is not None

x is not the same object as y

4.3. Assignments

4.3.1. Is None or not

Todo

poprawić zadanie, jest tendencyjne

  • Filename: types_none.py

  • Lines of code to write: 5 lines

  • Estimated time of completion: 5 min

  1. Co należy podstawić do zmiennych aby wyrażenia poniżej zgadzały się z wartością oczekiwaną?

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

print(a)    # True
print(b)    # False
print(c)    # True
print(d)    # False
print(e)    # False
The whys and wherefores
  • Definiowanie zmiennych

  • Konwersja typów

  • Typy logiczne