Witam!
Rozwiązuje sobie zadania z http://www.ii.uni.wroc.pl/~marcinm/dyd/python/listazad.pdf i co do zadania 1:
Rozwiązałem je niby ale mam wrażenie że mój kod jest trochę "słaby" (bardzo) chodź program działa :D
import random
a = 0
b=0
def rzut_kostka():
global a
global b
a = random.randint(1,6)
b = random.randint(1,6)
return True
x = input("Ile tur: ")
pointsplayer1 = 0
pointsplayer2 = 0
resultplayer1 = 0
resultplayer2 = 0
for i in range(x):
rzut_kostka()
print "Gracz 1: ","Dwa rzuty=",a+b
pointsplayer1 = a+b
print "Rzut pierwszy: ",a
print "Rzut drugi: ",b
rzut_kostka()
print "Gracz 2: ","Dwa rzuty=",a+b
pointsplayer2 = a+b
print "Rzut pierwszy: ",a
print "Rzut drugi: ",b
if pointsplayer1 > pointsplayer2:
resultplayer1 = resultplayer1+1
elif pointsplayer2 > pointsplayer1:
resultplayer2 = resultplayer2+1
elif pointsplayer2 == pointsplayer1:
print "Dogrywka!"
x = x-1
if i==x and resultplayer2 > resultplayer1:
print "#####################################"
print "Punkty gracza 1: ",resultplayer1
print "Punkty gracza 2: ",resultplayer2
print "Wygrał gracz 2: ",resultplayer2
print "#####################################"
elif i==x and resultplayer1 > resultplayer2:
print "#####################################"
print "Punkty gracza 1: ",resultplayer1
print "Punkty gracza 2: ",resultplayer2
print "Wygrał gracz 1: ",resultplayer1
print "#####################################"
elif i==x and resultplayer1 == resultplayer2:
print "#####################################"
print "DOGRYWA KOŃCZOŃCA GRE !"
print "#####################################"
i=i-1