How am I doing?
Jason
jason at jasonmhirst.co.uk
Sun Sep 18 19:48:57 EDT 2005
Please don't laugh, this is my FIRST Python script where I haven't
looked at the manual for help...
import string
import random
class hiScores:
hiScores=['10000Alpha','07500Beta','05000Gamma','02500Delta','00000Epsilon']
def showScores(self):
for entry in self.hiScores:
print entry[0:5]," - ",entry[5:]
def addScore(self,score,name):
newScore=string.zfill(score,5)
self.hiScores.append(newScore+name)
self.hiScores.sort(reverse=True)
if len(self.hiScores)==6:
del self.hiScores[-1]
a=hiScores()
print "Original Scores\n---------------"
a.showScores()
while 1:
newScore=random.randint(0,10000)
if string.zfill(newScore,5)>a.hiScores[4][0:5]:
print "Congratulations, you scored %d " % newScore
name=raw_input("Please enter your name :")
a.addScore(newScore,name)
a.showScores()
continue
Anything I could have done differently or any "bad-habits" you think I
have which could lead to ultimate doom I really appreciate to know.
TIA
More information about the Python-list
mailing list