1
0
This commit is contained in:
Lukas Blacha
2023-02-03 08:40:03 +01:00
parent 7a0b826d95
commit 5b19a8626e
5 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
# Python Basics - Code (IF - ELSE)
Mit Hife von IF / ELSE Statements kann man bestimmte Aktionen triggern, wenn eine bestimmte Kondition erfüllt ist.
**Beispiel anhand einer Altersprüfung**
> ```
> name = str(input("Bitte gib deinen Namen ein: "))
> alter = int(input("Bitte gibt dein Alter ein: "))
>
> if alter >= 18:
> print(f"Hallo {name}, du bist volljährig ({alter})")
> else:
> print(f"Hallo {name}, du bist minderjährig ({alter})")
> ```
**Genereller Aufbau für IF-Anweisungen**
> ```
> >>> if cond1:
> >>> pass
> >>> elif cond2:
> >>> pass
> >>> elif condn:
> >>> pass
> >>> else:
> >>> pass
> ```