Navigation überspringen

Operatoren in Python

Liste der ersten grundlegenden Operatoren

Arithmetische Operatoren

OperatorBedeutungBeispiel
+ 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

OperatorMeaningExample
> 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

OperatorMeaningExample
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)