1
0
Files
Python-Example/Einführung/04_Python-Basics-IF-ELSE.md
Lukas Blacha 5b19a8626e Rename
2023-02-03 08:40:03 +01:00

25 lines
626 B
Markdown

# 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
> ```