04
This commit is contained in:
Submodule Objektorientierung deleted from 0602206176
@@ -0,0 +1,2 @@
|
|||||||
|
# Objektorientierung
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
def auswertung():
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
zahl = int(input("Dein Tipp: "))
|
||||||
|
return zahl
|
||||||
|
except ValueError:
|
||||||
|
print("Bitte gib eine ganze Zahl ein.")
|
||||||
|
|
||||||
|
|
||||||
|
geheimzahl = random.randint(1, 100)
|
||||||
|
versuche = 0
|
||||||
|
|
||||||
|
print("Ich denke mir eine Zahl zwischen 1 und 100 aus.")
|
||||||
|
print("Versuche, sie zu erraten!")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
tipp = auswertung()
|
||||||
|
versuche += 1
|
||||||
|
|
||||||
|
if tipp < geheimzahl:
|
||||||
|
print("Zu klein!")
|
||||||
|
elif tipp > geheimzahl:
|
||||||
|
print("Zu groß!")
|
||||||
|
else:
|
||||||
|
print("Richtig!")
|
||||||
|
print("Du hast", versuche, "Versuche gebraucht.")
|
||||||
|
break
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
#Aufgabe1
|
||||||
|
#import random
|
||||||
|
#Anzahldersechsen = 0
|
||||||
|
#for i in range (0,99) :
|
||||||
|
# x = random.randint(1,6)
|
||||||
|
|
||||||
|
#if x == 6 :
|
||||||
|
# Anzahldersechsen = Anzahldersechsen +1
|
||||||
|
#print (Anzahldersechsen)
|
||||||
|
|
||||||
|
#Aufgabe 2 ratespiel
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
def auswertung():
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
zahl = int(input("Dein Tipp: "))
|
||||||
|
return zahl
|
||||||
|
except ValueError:
|
||||||
|
print("Bitte gib eine ganze Zahl ein.")
|
||||||
|
|
||||||
|
|
||||||
|
geheimzahl = random.randint(1, 100)
|
||||||
|
versuche = 0
|
||||||
|
|
||||||
|
print("Ich denke mir eine Zahl zwischen 1 und 100 aus.")
|
||||||
|
print("Versuche, sie zu erraten!")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
tipp = auswertung()
|
||||||
|
versuche += 1
|
||||||
|
|
||||||
|
if tipp < geheimzahl:
|
||||||
|
print("Zu klein!")
|
||||||
|
elif tipp > geheimzahl:
|
||||||
|
print("Zu groß!")
|
||||||
|
else:
|
||||||
|
print("Richtig!")
|
||||||
|
print("Du hast", versuche, "Versuche gebraucht.")
|
||||||
|
break
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
def auswertung():
|
||||||
|
noten = []
|
||||||
|
|
||||||
|
print("Zeugnis-Rechner")
|
||||||
|
print("Gib deine Noten ein.")
|
||||||
|
print("Gib 0 ein, wenn du fertig bist.")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
note = float(input("Note: "))
|
||||||
|
|
||||||
|
if note == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
if 1 <= note <= 6:
|
||||||
|
noten.append(note)
|
||||||
|
else:
|
||||||
|
print("Bitte eine Note zwischen 1 und 6 eingeben.")
|
||||||
|
|
||||||
|
except ValueError:
|
||||||
|
print("Bitte gib eine gültige Zahl ein.")
|
||||||
|
|
||||||
|
return noten
|
||||||
|
|
||||||
|
|
||||||
|
noten = auswertung()
|
||||||
|
|
||||||
|
if len(noten) > 0:
|
||||||
|
durchschnitt = sum(noten) / len(noten)
|
||||||
|
|
||||||
|
print("\nDeine Noten:", noten)
|
||||||
|
print("Anzahl der Noten:", len(noten))
|
||||||
|
print("Notendurchschnitt:", round(durchschnitt, 2))
|
||||||
|
else:
|
||||||
|
print("Es wurden keine Noten eingegeben.")
|
||||||
Reference in New Issue
Block a user