Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 39 additions & 44 deletions aufgaben/07_booleans.ipynb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"# Boolesche Werte\n",
"\n",
Expand All @@ -12,8 +12,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"Du kannst boolesche Werte in Variablen speichern, z.B.:\n",
">```python\n",
Expand All @@ -23,8 +23,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"Wir können zwei Variablen mit den folgenden Operatoren vergleichen:\n",
"\n",
Expand All @@ -39,8 +39,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"Kombiniere boolesche Ausdrücke mit den booleschen Operatoren:\n",
"- und (and)\n",
Expand All @@ -49,26 +49,24 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
"cell_type": "markdown",
"source": "---"
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"## Übung 1: Boolesche Operationen\n",
"\n",
"Schreibe ein Programm, das zwei Zahlen (**a** und **b**) vergleicht und ausgibt, ob **a** größer ist als **b**."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"a = 12\n",
Expand All @@ -78,8 +76,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"## Übung 2: E-Mail Rechtschreibprüfung\n",
"\n",
Expand All @@ -95,10 +93,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"email1 = input(\"Bitte gib deine E-Mail-Adresse ein: \")\n",
Expand All @@ -108,8 +106,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"## Übung 3: Anzahl wahrer Ausdrücke\n",
"\n",
Expand All @@ -123,10 +121,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"a = 13\n",
Expand All @@ -141,52 +139,49 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"## Übung 4: Boolesche Algebra\n",
"\n",
"Erstelle 3 Variablen (**p**, **q** und **r**) und speichere in jeder einen booleschen Wert (True/False).\n",
"Schreibe ein Programm, das überprüft, ob eine Person berechtigt ist, an einem Wettbewerb teilzunehmen.\n",
"\n",
"Gib nun aus, ob der folgende boolesche Ausdruck wahr oder falsch ist:\n",
"> (**p** und **q** sind wahr) oder (**q** ist falsch oder **r** ist wahr)"
"Regeln für die Teilnahme:\n",
"Die Person muss mindestens 18 Jahre alt sein und weniger als 60 Jahre alt.\n",
"Oder: Die Person kann unabhängig vom Alter teilnehmen, wenn sie ein VIP-Status besitzt."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"p = True\n",
"q = True \n",
"r = False\n",
"alter = int(input(\"Bitte gib dein Alter ein: \"))\n",
"vip_status = bool(input(\"Bist du VIP? (True/False): \"))\n",
"\n",
"ergebnis = (p and q) or (not q or r)\n",
"\n",
"print(ergebnis)"
"print((alter >= 18 and alter < 60) or vip_status)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
"cell_type": "markdown",
"source": "---"
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"## Bonus-Übungen\n",
"\n",
"Wenn du viel schneller als die anderen bist, versuche die folgenden Übungen zu lösen:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"### Bonus-Übung 1: Teilbarkeitsüberprüfung\n",
"\n",
Expand All @@ -196,10 +191,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"zahl = 12\n",
Expand All @@ -209,8 +204,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"### Bonus-Übung 2: Schaltjahrüberprüfung\n",
"\n",
Expand All @@ -220,10 +215,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"jahr = 2020\n",
Expand All @@ -232,8 +227,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"### Bonus-Übung 3: Palindrom-Überprüfung\n",
"\n",
Expand All @@ -243,10 +238,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Schreibe deinen Code unter diese Zeile\n",
"wort = input(\"Bitte gib ein Wort ein: \")\n",
Expand All @@ -255,8 +250,8 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "markdown",
"source": [
"## Feedback\n",
"Bitte scanne den QR-Code unten, um uns dein Feedback zu **Kapitel 07: Boolesche Werte** zu geben\n",
Expand Down
13 changes: 4 additions & 9 deletions exercises/07_booleans.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,8 @@
"source": [
"## Exercise 4: Boolean algebra\n",
"\n",
"Create 3 variables (**p**, **q** and **r**) and store a boolean value (True/False) in each of them.\n",
"\n",
"Now print whether the foollowing boolean expression is true or false: \n",
"> (**p** and **q** are true) or (**q** is false or **r** is true)"
"Write a program that checks if a person is eligible to participate in a competition. Rules for participation: The person must be at least 18 years old and less than 60 years old. Or: The person can participate regardless of age if they have VIP status."
]
},
{
Expand All @@ -211,13 +209,10 @@
],
"source": [
"# write your code after this line\n",
"p = True\n",
"q = True\n",
"r = False\n",
"age = int(input(\"Please enter your age: \"))\n",
"vip_status = bool(input(\"Are you a VIP? (True/False): \"))\n",
"\n",
"result = (p and q) or (not q and r)\n",
"\n",
"print(result)"
"print((age >= 18 and age < 60) or vip_status)"
]
},
{
Expand Down