ブール演算子

Intermediate Python for Finance

Kennedy Behrman

Data Engineer, Author, Founder

ブール論理

ジョージ・ブール

Intermediate Python for Finance

ブール演算とは?

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

オブジェクトの評価

False と評価されるもの

  • 定数:

    • False
    • None
  • 数値のゼロ:

    • 0
    • 0.0
  • 長さが 0

    • ""
    • []
    • {}

True と評価されるもの

  • それ以外ほぼすべて
Intermediate Python for Finance

AND 演算子

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

OR 演算子

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

ショートサーキット

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

NOT 演算子

not True
False
not False
True
Intermediate Python for Finance

NOT の演算順序

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

オブジェクトの評価

"CUSIP" and True
True
Intermediate Python for Finance

オブジェクトの評価

[] or False
False
Intermediate Python for Finance

オブジェクトの評価

not {}
True
Intermediate Python for Finance

オブジェクトを返す場合

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

オブジェクトを返す場合

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

Ayo berlatih!

Intermediate Python for Finance

Preparing Video For Download...