Die Und-Verknüpfung in Python
Häufig ist der Einsatz zur Und-Verknüpfung zweier Aussagen:
- Protokoll
False and False
False
- Protokoll
False and True
False
- Protokoll
True and False
False
- Protokoll
True and True
True
- Protokoll
1<2 and 2<3
True
Dafür könnte man in Python aber auch schreiben:
- Protokoll
1<2<3
True
jedoch geht dies nicht mehr so direkt bei:
- Protokoll
1<2 and 102<103
True
Weitere Beschreibung °
Falls der erste Wert als falsch gilt, ist er das Ergebnis, sonst der zweite Wert
Als falsch gelten: ›False‹, ›None‹, «0», «0.0», und «""».
- Protokoll
'abc' and 'def'
'def'
- Protokoll
'' and 'def'
''
- Protokoll
12 and 14
14
- Protokoll
0.0 and 1.0
0.0
- Protokoll
1.0 and 0.0
0.0
Syntaktische Eigenschaften
- Eigenschaften von Operatoren – Operatoren höherer Priorität stehen weiter oben
S P A
() 1 Z
** 2 I R
+, - 1 P
*, / 2 I L
+, - 2 I L
==, is, !=, <, >, <=, >=, in, not in 2 I
not 1 P
and 2 L