Booleovské operátory

Intermediate Python for Finance

Kennedy Behrman

Data Engineer, Author, Founder

Booleova logika

George Boole

Intermediate Python for Finance

Co jsou booleovské operace?

  1. and
  2. or
  3. not
Intermediate Python for Finance

Vyhodnocení objektů

Vyhodnocuje se jako False

  • Konstanty:

    • False
    • None
  • Číselná nula:

    • 0
    • 0.0
  • Nulová délka

    • ""
    • []
    • {}

Vyhodnocuje se jako True

  • Téměř vše ostatní
Intermediate Python for Finance

Operátor AND

True and True
True
True and False
False
Intermediate Python for Finance

Operátor OR

False or True
True
True or True
True
False or False
False
Intermediate Python for Finance

Zkrácené vyhodnocení.

is_current() and is_investment()
False
is_current() or is_investment()
True
Intermediate Python for Finance

Operátor NOT

not True
False
not False
True
Intermediate Python for Finance

Priorita operátoru NOT

True == False
False
not True == False
True
Intermediate Python for Finance

Vyhodnocení objektů

"CUSIP" and True
True
Intermediate Python for Finance

Vyhodnocení objektů

[] or False
False
Intermediate Python for Finance

Vyhodnocení objektů

not {}
True
Intermediate Python for Finance

Vracení objektů

"Federal" and "State"
"State"
[] and "State"
[]
Intermediate Python for Finance

Vracení objektů.

13 or "account number"
13
0.0 or {"balance": 2200}
{"balance": 2200}
Intermediate Python for Finance

Pojďme si procvičit!

Intermediate Python for Finance

Preparing Video For Download...