Restructured the entire folder and added this lesson's examples
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# Ablauf der Stunde:
|
||||
|
||||
# 1. Ausgabe
|
||||
|
||||
print("hello world")
|
||||
|
||||
# 2. Variablen
|
||||
|
||||
name = "Max Mustermann" # eigenen Namen wählen
|
||||
print(name)
|
||||
|
||||
# 3. Benutzereingabe
|
||||
|
||||
print("Hallo. Ich bin ein Chatbot.")
|
||||
name = input("Wie heißt du?: ")
|
||||
print("Hallo", name)
|
||||
|
||||
# 4. Bedingungen
|
||||
|
||||
print("Hallo. Ich bin ein Chatbot.")
|
||||
name = input("Wie heißt du?: ")
|
||||
if name == "Max Mustermann":
|
||||
print("Hallo Max!")
|
||||
else:
|
||||
print("Hallo", name)
|
||||
|
||||
# 5. Schleifen
|
||||
|
||||
print("Hallo. Ich bin ein Chatbot.")
|
||||
while True:
|
||||
name = input("Wie heißt du?: ")
|
||||
if name == "Max Mustermann":
|
||||
print("Hallo Max!")
|
||||
else:
|
||||
print("Hallo", name)
|
||||
break # nur für die Demo
|
||||
|
||||
|
||||
# 6. Funktionen
|
||||
|
||||
def chatbot(username):
|
||||
print("Hallo. Ich bin ein Chatbot.")
|
||||
name = input("Wie heißt du?: ")
|
||||
if name == username:
|
||||
print("Hallo Max!")
|
||||
else:
|
||||
print("Hallo", name)
|
||||
|
||||
chatbot("Max Mustermann")
|
||||
|
||||
# ...
|
||||
@@ -0,0 +1,20 @@
|
||||
print("Hallo! Ich bin ein Chatbot.")
|
||||
name = input("Wie heißt du?: ")
|
||||
|
||||
print("Hallo", name)
|
||||
|
||||
while True:
|
||||
text = input("> ")
|
||||
|
||||
if text == "hallo":
|
||||
print("Hallo!")
|
||||
|
||||
elif text == "wie gehts":
|
||||
print("Gut :)")
|
||||
|
||||
elif text == "bye":
|
||||
print("Tschüss!")
|
||||
break
|
||||
|
||||
else:
|
||||
print("Das verstehe ich nicht.")
|
||||
Reference in New Issue
Block a user