Inhaltsverzeichnis
Philipp
Zahlenraten
- zahlenraten.py
# -*- coding: utf-8 -*- import random x = random.randint(1,1000) a=1 versuche=0 while a > 0: a = input("rate meine zahl:") versuche+=1 if a==x: print "Gewonnen" break elif a>x: print "Zu Hoch" else: print "zu tief" print "game over" print "%i versuche"%versuche
Zahlenraten2
Für dieses Programm braucht man easygui: http://easygui.sf.net
- zahlenraten2.py
# -*- coding: utf-8 -*- import random import easygui as e x = random.randint(1,1000) a=1 versuche=0 liste = ["dummer", "groser", "bloeder", "kleiner", "feiner", "schrumpfkoepfiger"] liste2 = ["tisch","sessel","wombat","computer","zug","hamster","magnet", "kassten","ofen","kochtopf"] ergebnis = "" history1 = "" history2 = "" history3 = "" while a >= 0: versuche+=1 a = e.integerbox("%s\n%s\n%s\n rate meine zahl:"% (history3,history2,history1),"rateversuch %i"% versuche,0,0,1000) if a==x: e.msgbox("Gewonnen") break elif a>x: ergebnis = "\nZu hoch du %s %s %s"%(random.choice(liste),random.choice(liste),random.choice(liste2)) else: ergebnis = "\nZu tief du %s %s %s"%(random.choice(liste),random.choice(liste),random.choice(liste2)) history3 = history2 history2 = history1 history1 = "%i: %s" % (a,ergebnis) e.msgbox("%i versuche"%versuche,"Game over")
- schild2.py
# -*- coding: utf-8 -*- import random as r import turtle as t t.speed(0) def haus(hoehe): """Zeichne dein Haus""" t.fd(100) t.left(90) t.fd(hoehe) t.left(90) t.fd(100) t.left(90) t.fd(hoehe) t.left(90) t.left(90) t.fd(hoehe) t.right(45) t.fd(70) t.right(90) t.fd(70) t.pu() t.right(45) t.fd(hoehe) t.right(90) t.fd(100) t.right(180) t.pu() t.fd(-600) t.right(90) t.fd(200) t.left(90) for y in range(2): for x in range(10): t.pu() t.fd(100) t.pd() haus(r.randint(8,150)) t.pu() t.right(270) t.fd(255) t.right(90) t.fd(-1000)






