and |
as |
assert |
async |
await |
break |
class |
continue |
def |
del |
elif |
else |
except |
False |
finally |
for |
from |
global |
if |
import |
in |
is |
lambda |
None |
nonlocal |
not |
or |
pass |
raise |
return |
True |
try |
while |
with |
yield |
x = 4
y = 5
summe = x+y
print(summe)
name="Holzer"
vorname="Roland"
print(vorname+" "+name)
>>> %Run var.py 9 Roland Holzer
| Operator | Bedeutung | Beispiel |
|---|---|---|
| + | Plus | 4+5+3.2 |
| - | Minus | 4-5 |
| - | Vorzeichen-Minus | -3 oder -x |
| * | Mal | 2*3.1415*r |
| / | Teilen (Ergebnis ist eine Kommazahl) | 1/3 ergibt 0.333333 |
| ** | Hoch | 2**3 ist 2*2*2 |
| % | Teilungsrest | 6%4 ist 2 da 6:4= 1 Rest 2 |
| // | Ganzzahliges teilen | 6//4 ist 1 |
| Operator | Bedeutung | Beispiel |
|---|---|---|
| + | Anhängen (concatination) | "Hallo"+" Du" ergibt "Hallo Du" |
| * | Vervielfachen | "*-"*5 ergibt "*-*-*-*-*-" |
x = "hallo"+3 ergibt den Fehler TypeError: can only concatenate str (not
"int") to str
str(...).text = "Ich bin "+str(44)+" Jahre alt".
-#-#-#-#-# usw sein.
y=3x+1 eingibt?y=3*x+1 eingibt? Also diesmal mit dem *-Zeichen.