diff --git a/aufgaben/07_booleans.ipynb b/aufgaben/07_booleans.ipynb index d07fa48..e3f87ff 100644 --- a/aufgaben/07_booleans.ipynb +++ b/aufgaben/07_booleans.ipynb @@ -1,8 +1,8 @@ { "cells": [ { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "# Boolesche Werte\n", "\n", @@ -12,8 +12,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "Du kannst boolesche Werte in Variablen speichern, z.B.:\n", ">```python\n", @@ -23,8 +23,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "Wir können zwei Variablen mit den folgenden Operatoren vergleichen:\n", "\n", @@ -39,8 +39,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "Kombiniere boolesche Ausdrücke mit den booleschen Operatoren:\n", "- und (and)\n", @@ -49,15 +49,13 @@ ] }, { - "cell_type": "markdown", "metadata": {}, - "source": [ - "---" - ] + "cell_type": "markdown", + "source": "---" }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "## Übung 1: Boolesche Operationen\n", "\n", @@ -65,10 +63,10 @@ ] }, { - "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", @@ -78,8 +76,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "## Übung 2: E-Mail Rechtschreibprüfung\n", "\n", @@ -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", @@ -108,8 +106,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "## Übung 3: Anzahl wahrer Ausdrücke\n", "\n", @@ -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", @@ -141,43 +139,40 @@ ] }, { - "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", @@ -185,8 +180,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "### Bonus-Übung 1: Teilbarkeitsüberprüfung\n", "\n", @@ -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", @@ -209,8 +204,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "### Bonus-Übung 2: Schaltjahrüberprüfung\n", "\n", @@ -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", @@ -232,8 +227,8 @@ ] }, { - "cell_type": "markdown", "metadata": {}, + "cell_type": "markdown", "source": [ "### Bonus-Übung 3: Palindrom-Überprüfung\n", "\n", @@ -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", @@ -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", diff --git a/exercises/07_booleans.ipynb b/exercises/07_booleans.ipynb index 5a873a9..36071e3 100644 --- a/exercises/07_booleans.ipynb +++ b/exercises/07_booleans.ipynb @@ -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." ] }, { @@ -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)" ] }, {