41 lines
842 B
Python
41 lines
842 B
Python
#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 |