Operatoren in Python
Arithmetische Operatoren
Operator | Bedeutung | Beispiel |
+ |
Addition |
x + y |
- |
Subtraktion |
x - y |
* |
Multiplikation |
x * y |
/ |
Division |
x / y |
% |
Modulo (Restwertrechner) |
x % y Rest von x/y |
// |
Teilung mit Abrunden |
x // y |
** |
Exponentenrechnung |
x**y (x hoch y) |
Vergleichsoperatoren
Operator | Meaning | Example |
> |
größer als |
x > y |
< |
kleiner als |
x < y |
== |
gleich (ACHTUNG: keine Zuweisung) |
x == y |
!= |
nicht gleich |
x != y |
>= |
größer gleich |
x >= y |
<= |
kleiner gleich |
x <= y |
Logische Operatoren
Operator | Meaning | Example |
and |
Logisch-UND |
x and y |
or |
Logisch-ODER |
x or y |
not |
Logisch-NICHT |
not x |
x = True
y = False
# Output: x and y is False
print('x and y is',x and y)
# Output: x or y is True
print('x or y is',x or y)
# Output: not x is False
print('not x is',not x)