[Tutor] G'day

2006-02-15 Thread John Connors


G'day, I'm new to Python and new to the list and just thought I'd say a quick hello before asking my 1st dumb question. My name is John and I live in Australia,  I've been using computers since about 1983. I haven't done any programming since the commodore 64 basic days, I was fairly proficient with basic so I'm hoping I can pick up python without too much grief. I'm running Fedora Core 4 and using Python 2.4.1. My 1st dumb question: I have a copy of Teach Yourself Python in 24 Hours, printed in 2000 so I guess it's virtually usless but i was hoping to learn some of the basics from it. There is a small bit of code near the beginning... print "Hello, World!"print ' 'Goodbye, World!" which returns a syntax error for the 2nd line. I thought it was a typo and changed it to print "Goodbye, World!".  This would be fine except further on the book there is similar syntax in some of the longer scripts. My guess is that syntax was ok for an older version of Python that book was written for.  I would like to know what the correct code should be. JohnExpress yourself instantly with MSN Messenger! MSN Messenger
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] G'day

2006-02-18 Thread John Connors
G'day,

Thanks to the people who replied, I only found them today and hopefully I 
didn't miss any. For some reason hotmail was sending them to junk even 
though it allowed the 1st message through and I had added tutor@python.org 
to my contact list. Should be sorted now I hope!

> > print "Hello, World!"
> >
> > print ' 'Goodbye, World!"
>
>If you are referring to the bit on page 25 it is the same style of
>quote in both examples in my copy of the book. Are you sure
>its different? Or are you looking at another page?

It was a library book and I have taken it back, there was typos all through 
it. I figured out that most of the syntax errors I was getting were from 
incorrect indentation. I knew indentation was important in python but I 
didn't realise it would return a syntax error if it was wrong. Not the 
authors fault BTW, just errors in the printing I think.

I'm now using an ebook I found called Dive Into Python. I much prefer using 
a book so I can duck back a few pages to refresh my memory and reading on 
the monitor is a real pain. It seems an excellent reference though so I'll 
get around to printing it out sooner or latter (when the Mrs isn't here so 
she won't complain about me wasting ink and paper).

John

_
realestate.com.au: the biggest address in property   
http://ninemsn.realestate.com.au

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] First Try

2006-02-19 Thread John Connors
G'day :)

I started getting sick of reading tutorials so for a bit of a break I set 
myself the task of writing a program to pick lotto numbers, 6 numbers 
between 1 and 44 (inclusive). I had done this many years before in basic and 
I thought back then it would be a simple task but I struck a problem of the 
random number generator repeating numbers occasionally so I had to check 
each number against the other and generate another random number if there 
were duplicates.

So I was prepared for the same problem with python but I found that python 
takes care of that for me so the program would only have to be one line. I 
decided to make it a little more user friendly and allow the user to pick 
home many games they want generated. Then I made the output a little easier 
to read with a few blank lines. Here is what I came up with:


import random

numberof = int(raw_input('Enter how many games you would like generated :')) 
#user input for number of games to choose

print
print
print "Here are your numbers :"
print

for games in range(1, numberof + 1): #loop for the number of games selected 
by user
lotto = random.sample(xrange(1,45), 6) #generate 6 random numbers 
between 1 and 44 inclusive
print games, lotto
print

else:
print
print "Hope you win!"


I know this is a very simple program but... could I have done this a better 
way?

John

_
Search for local singles online @ Lavalife - Click here  
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D21550&_t=21550&_r=endtext&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] First Try 1.1

2006-02-20 Thread John Connors

G'day,

Thanks for the input on my lotto number selector program, very much 
appreciated and I learnt a lot. I've (hopefully) cleaned it up a little, and 
expanded it to write the numbers to a text file. I'm sure there must be a 
better way of doing it then the way I have.


I understand that the "else" is not neccessary for the program to work but 
should I include it to show the end of the loop? I guess it's not important 
in a program like this that has only 1 loop but maybe it makes reading more 
complcated programs easier or is the indentation sufficient?




import random

# create or replace lotto.txt in my home directory
file('/home/mutt/lotto.txt','w').write('Here are your numbers:\n\n')

# user input for number of games to choose
how_many_games = int(raw_input('Enter how many games you would like 
generated : '))


print '\n\nHere are your numbers : \n'

# loop for the number of games selected by user
for game in range(1, how_many_games + 1):

   # generate 6 random numbers between 1 and 45 inclusive
   lotto_numbers = random.sample(xrange(1,46), 6)

   # Right justified in 3 character width then a tab (\t) then a blank line 
(\n)

   print '%3s\t%s\n' % (game, lotto_numbers)

   # append the numbers to lotto.txt
   file('/home/mutt/lotto.txt','a').write('Game: ')
   file('/home/mutt/lotto.txt','a').write(str(game))
   file('/home/mutt/lotto.txt','a').write('')
   file('/home/mutt/lotto.txt','a').write(str(lotto_numbers))
   file('/home/mutt/lotto.txt','a').write('\n')

print '\nHope you win!'
file('/home/mutt/lotto.txt','a').write('\n\nHope you win!')

John

_
New year, new job – there's more than 100,00 jobs at SEEK 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] First Try 1.2

2006-02-21 Thread John Connors
G'day :)

I've added a little more to the program. It now sorts the game numbers from 
lowest to highest which makes filling out the tickets a lot easier, I've 
been putting off doing this because I wasn't sure how to go about it but 
once I started looking I found python does it all for me with .sort()

Also added some extra user input so different types of lotto games can be 
played.

Found a glaring bug...the program didn't pick the winning numbers for me and 
I'm now $6 poorer! 

Next on the to do list is add an option for a power ball, I actually did 
this tonight but I had 'if' statements all over the place. Which made the 
code unreadable so I'm going to work on a different way of doing it.

I hope posting my efforts in here is ok. I learnt a lot after posting the 
first version of it but if I'm doing the wrong thing please tell me and I'll 
desist.


import random

# create or replace lotto.txt in my home directory
file('/home/mutt/lotto.txt','w').write('Here are your numbers:\n\n')

# user input for number of games to generate
how_many_games = int(raw_input('How many games you would like generated? '))

# user input for number of balls (to allow different lotto games)
number_of_balls = int(raw_input('\nHow many balls are in the lotto you wish 
to play? '))

# user input for how many numbers per game (to allow systems entries)
how_many_numbers = int(raw_input('\nHow many numbers you would like per 
game? '))

print '\n\nHere are your numbers : \n'

# loop for the number of games selected by user
for game in range(1, how_many_games + 1):

# generate 6 random numbers between 1 and 45 inclusive
lotto_numbers = random.sample(xrange(1,number_of_balls + 1), 
how_many_numbers)
lotto_numbers.sort()

# Right justified in 3 character width then a tab (\t) then a blank line 
(\n)
print '%3s\t%s\n' % (game, lotto_numbers)

# append the numbers to lotto.txt
file('/home/mutt/lotto.txt','a').write('Game: ')
file('/home/mutt/lotto.txt','a').write(str(game))
file('/home/mutt/lotto.txt','a').write('')
file('/home/mutt/lotto.txt','a').write(str(lotto_numbers))
file('/home/mutt/lotto.txt','a').write('\n')

print '\nHope you win!'
file('/home/mutt/lotto.txt','a').write('\n\nHope you win!')


John

_
Search for local singles online @ Lavalife - Click here  
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D21550&_t=21550&_r=endtext&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] First Try 1.2

2006-02-22 Thread John Connors
G'day,

Added a power ball option to the lotto program today. The program does way 
more then I ever intended when I started it so I'll try a new project. Maybe 
I'll come back to it when I try out Tkinter and try to give it a GUI.

Anywayhere's my latest effort.


import random

# store the /home/mutt/lotto.txt in f
f = file('/home/mutt/lotto.txt','w')
# create or replace lotto.txt in my home directory
f.write('Here are your numbers:\n\n')

# user input for number of games to generate
how_many_games = int(raw_input('How many games you would like generated? '))
# user input for number of balls (to allow different lotto games)
number_of_balls = int(raw_input('\nHow many balls are in the lotto you wish 
to play? '))
# user input for how many numbers per game (to allow systems entries)
how_many_numbers = int(raw_input('\nHow many numbers you would like per 
game? '))
# check if there is a power ball
chk_pwrball = raw_input('Is there a power ball? (y/n) ')

print '\n\nHere are your numbers : \n'

# loop for the number of games selected by user
for game in range(1, how_many_games + 1):

# generate 6 random numbers between 1 and 45 inclusive then sort them
lotto_numbers = random.sample(range(1,number_of_balls + 1), 
how_many_numbers)
lotto_numbers.sort()

if chk_pwrball == 'n':

# Right justified in 3 character width then a tab (\t) then a blank 
line (\n)
print '%3s\t%s\n' % (game, lotto_numbers)

# write the numbers to lotto.txt
save_numbers = 'Game: %3s\t%3s\n' % (game, lotto_numbers)
f.write(save_numbers)

if chk_pwrball == 'y':
pwrball = random.sample(range(1,number_of_balls +1), 1)
print '%3s\t%s   \tPower Ball: %s\n' % (game, lotto_numbers, 
pwrball)
save_numbers = 'Game: %3s\t%s   \tPower Ball: %s\n' % (game, 
lotto_numbers, pwrball)
f.write(save_numbers)

print '\nHope you win!'
f.write('\nHope you win!')
f.close()



John

_
Shopping made easy @ tradingpost.com.au 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fwww%2Etradingpost%2Ecom%2Eau%2F%3Freferrer%3DnmsnHMetagv1&_t=753082530&_r=emailtagline&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Repeating a routine

2006-02-22 Thread John Connors

G'day,

With my only programming experience being C-64 Basic I'm finding that I 
struggle a bit understanding some of the concepts of Python, I wish I could 
block basic right out of my brain.


One of the things I can't get a grasp of is how to repeat a routine many 
times. For example a simple dice game where 6 dice are rolled, any that come 
up as 1 are kept, you keep rolling the dice until a 1 is not rolled.


A program to do that would need to generate a random number between 1 and 6 
many times. In basic I would have made a sub routine for the random number. 
Only way I can think of to do it in python is to have a seperate script.


And at the end of the game I might want to play again and it would be nice 
to have something like - Play dice game again (y/n). I'm not sure how to run 
the program again other then re-loading it.


I know goto and gosub are evil, bad habits but I'm starting to miss them.

John

_
New year, new job – there's more than 100,00 jobs at SEEK 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] First Try 1.2

2006-02-22 Thread John Connors
G'day Kent,

Thanks for the input.

>The comments don't really add anything to the program. Comments that
>restate exactly what the code is doing are not that helpful. The code
>should be clear by itself. As a beginner they may seem like a helpful 
>crutch but you will get better at reading the code.

Very good point. I have to go away for 3 weeks in a couple of days and I was 
trying to leave helpful hints to myself in the code so I won't forget what I 
have learnt. But you are right, I got carried away and most were just 
getting in the way.

John

_
Shopping made easy @ tradingpost.com.au 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fwww%2Etradingpost%2Ecom%2Eau%2F%3Freferrer%3DnmsnHMetagv1&_t=753082530&_r=emailtagline&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Repeating a routine

2006-02-22 Thread John Connors
G'day,

I think my peanut sized brain is starting to understand how to do this. I 
tried with a simple dice game where 4 dice are rolled, if the total of the 
last 2 dice rolled is 6 you win. It's kinda pointless using 4 dice rolls 
when only 2 are needed but I wanted to prove to myself I could call the dice 
function whenever I needed it.

This is what I came up with.


import random

def dice():
return random.randint(1,6)

playagain = 'y'

while playagain == 'y':

die1 = dice()
die2 = dice()

print '1st dice is ',die1,'\n','2nd dice is ',die2

die3 = dice()
die4 = dice()
winnum = die3 + die4

print'combined total for the next 2 dice is ',winnum

if winnum == 6:
print 'you win'
else:
print 'you lose'

playagain = raw_input('play again? (y/n) ')

print 'goodbye'

_
Make your dream car a reality 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fcarpoint%2Eninemsn%2Ecom%2Eau&_t=12345&_r=emailtagline&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Repeating a routine

2006-02-22 Thread John Connors
G'day Sean,

>Jumping to the middle of a book or movie will lead to similar confusion.
>
>Give a look at Dive Into Python. Available as either a book or online.

I have it and it's a great book, and I have worked my way through a lot of 
it unfortunately my brain can't take something in unless I do it myself. I 
learnt more by trying a couple of simple programs and posting them in here 
then I did by several weeks of reading books and tutorials. It's not the 
books fault it's just the way my brain works.

I certainly appreciate the time and effort of those who assist in here. 
Sorry if I've done the wrong thing.

John

_
Search for local singles online @ Lavalife - Click here  
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D21550&_t=21550&_r=endtext&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Importing Modules

2006-04-24 Thread John Connors

G'day,

I'm having trouble understanding the difference between,

import sys
and
from sys import *

It seems to me they both do the same thing.

John

_
New year, new job – there's more than 100,00 jobs at SEEK 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to compile _tkinter in Fedora Core 4

2006-04-25 Thread John Connors

G'day John,

There is a problem with a recent python update and fedora, if you go to 
http://forums.fedoraforum.org/ and do a search in the forum for tkinter 
and/or idle you will find the fix.


I'm running Fedora Core 5 and found I had to install tkinter, I had to do a 
yum install tkinter.


John


From: John Hsu <[EMAIL PROTECTED]>
To: Python Tutor 
Subject: [Tutor] How to compile _tkinter in Fedora Core 4
Date: Tue, 25 Apr 2006 17:11:32 +1200

Hi

I'd very much appreciate your help if you can advise me how to compile
_tkinter in Fedora 4. I installed Fedora core 4 in my machine recently,
but struggled to get Tk working for me.

The Tcl/Tk is working O.K. because I can run demo programs from
/usr/share/tk8.4/demos. The error is caused by missing _tkinter library,
and clearly there is no Tkinter module to be imported.

I managed to download and recompile a  new version of  Python (2.4.3),
then run "make test".  The error message says:

...
test_tcl
test_tcl skipped -- No module named _tkinter
...
1 skip unexpected on linux2:
test_tcl
...

John Hsu




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


_
New year, new job – there's more than 100,00 jobs at SEEK 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Checking in lists

2006-04-26 Thread John Connors

G'day,

I found something today that has me confused. I'm making a list of 6 random 
dice rolls and I want to check if any 1's or 5's were rolled. I tried this 
way first and it returns true even if there are no 1's or 5's. I'll use a 
roll of all 2's as an example.


rollList = [2,2,2,2,2,2]
if 1 or 5 in rollList:
  print 'yes'
else:
  print 'no'

Then I tried this and it works fine.

rollList = [2,2,2,2,2,2]
if 1 in rollList or 5 in rollList:
  print 'yes'
else:
  print 'no'

It doesn't really matter because the second way does what I want but I would 
like to know why the first way doesn't work and if the syntax is wrong why 
doesn't it return an error.


John

PS I apologise if this is a duplicate, hotmail did some kind of spam check 
when I tried to send it, I've waited 30 mins and I don't think it went the 
1st time so I'll post it again.


_
New year, new job – there's more than 100,00 jobs at SEEK 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread John Connors
G'day Payal,

I had trouble understanding the namespaces section of the tutorial too but 
it all clicked the other day when Alan explained the difference between 
import first and from first import *

John

>Hi,
>In Alan's tutorial I haven't got the example of print42() even after
>reading the explanation.
>I get 110 if I use it as a function.
>
> >>> spam = 42
> >>> def print42(): print spam
>...
> >>> spam = 110
> >>> print42()
>110
>
>Why do you get 42 when you use it as module? I haven't understood the
>explantaion.
>
>With warm regards,
>-Payal
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

_
15,000 Velocity Points Velocity NAB Credit Card 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fadsfac%2Enet%2Flink%2Easp%3Fcc%3DNAT030%2E23080%2E0%26clk%3D1%26creativeID%3D34301&_t=754983092&_r=emailtagline&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread John Connors
G'day Alan,

>However I'll refrain from saying much more since I do think the
>namespaces topic could be significantly improved if only I could
>find better words and examples.
>
>So please everyone, feel free to try to explain this idea to Payal
>so that I can steal your ideas for the tutorial!!  :-)

Maybe it would would be a good idea to say that the first part of the 
example has to be saved as first.py before the example works.

And maybe an explanation of the difference between import module and from 
module import * .It seems so simple now but until I understood that I 
couldn't understand the namespaces part of the tutorial.

John

_
Bounce Back from sickness and injury today. 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fclk%2Eatdmt%2Ecom%2FMOS%2Fgo%2Fnnmsngem001007mos%2Fdirect%2F01%2F&_t=753470755&_r=HM_Tagline_Apr06&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How Big Is Too Big?

2006-04-29 Thread John Connors

G'day,

Just wondering how many lines of code is the maximum to post in the list to 
have it critiqued. I realise people are using their own time to help others 
in here for no real personal gain and I would hate to impose on their 
goodwill. Would about 100 lines of code be considered too much?


John

_
New year, new job – there's more than 100,00 jobs at SEEK 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Silly Dice Game

2006-04-29 Thread John Connors
G'day,

The wife and I play a silly dice game and I thought it would be a good 
challange for me to write it as a program. No specific question, just 
wondering if my technique is ok and is there anything that could be done 
better. The 2 hardest things I find as a python beginner who has no real 
need to learn a programming language other than curiosity and too much spare 
time, are thinking of something to program and then knowing if what I have 
written could be done more efficiently.



import random

def removeDice():
for a in range(3):
dieList.remove(checkThree)

while True:

dieLeft = 6
totalScore = 0

while dieLeft > 0:

dieList = []
score = 0

# roll the dice
if dieLeft == 6:
raw_input("\nPress enter to roll the dice ")
print
for dieRoll in range(dieLeft):
dieList.append(random.randint(1,6))
print "Die roll %d is %d" % (dieRoll +1, dieList[dieRoll])
dieList.sort()

if dieLeft == 6:

#check if all dice are the same
for fatChance in range(1,7):
if dieList.count(fatChance) == 6:
score += 5000
dieLeft = 0
print "\nYou rolled all %d's, WoW!!!" % (fatChance)

#check for a straight
if dieList == [1,2,3,4,5,6]:
score += 1500
dieLeft = 0
print "\nYou rolled a straight"

#check for 3 pairs
if dieLeft == 6:
if dieList[0] == dieList[1] and dieList[2] == dieList[3] and 
dieList[4] == dieList[5]:
score += 1500
dieLeft = 0
print"\nYou rolled three pairs"

#check for 3 of a kind
if dieLeft > 2:

for checkThree in range(1,7):

if dieList.count(checkThree) >= 3:
print "\nYou rolled three %d's" % (checkThree)
yourChoice = raw_input("\nDo you wish to keep them? y/n 
")

if yourChoice == 'y':
dieLeft -= 3

if checkThree == 1:
score += 1000
removeDice()
else:
score = score + checkThree * 100
removeDice()

#check for 1's and 5's
if 1 in dieList or 5 in dieList:

for testDice in range(dieLeft):

if dieList[testDice] == 1:
score += 100
dieLeft -= 1

if dieList[testDice] == 5:
score += 50
dieLeft -= 1

totalScore = totalScore + score

if score != 0:
print "\nYour score is %d and you have %d dice left" % 
(totalScore, dieLeft)

if score == 0:
print "\nYou busted and score nothing"
totalScore = 0
break

if dieLeft >= 1:
rollAgain = raw_input ("\nRoll the remaining dice? y/n ")

if rollAgain != "y":
break

if dieLeft == 0:
dieLeft = 6
print "\nYou used all the dice and must roll again"

print "\n\nYour total score for that round was %d" % (totalScore)
playAgain = raw_input("\nPlay again? (y/n) ")
print

if playAgain != "y":
break



John

_
realestate.com.au: the biggest address in property   
http://ninemsn.realestate.com.au

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Silly Dice Game

2006-04-29 Thread John Connors
G'day John,

>If I were you, I would look at separating more of my program out into
>functions.  Good use of functions will make your program more
>readable, easier to debug, and easier to change, should the rules of
>your dice game change :-)

Yes, the rules change on a regular basis, usually by the wife when I start 
to win :)

>Do you understand what is going on there?

Some of the commands are new to me but I think I understand what's going on. 
I was assuming that functions were only really useful if they were used more 
than once but I see what you mean about them making a program easier to read 
and debug.

Thanks.

John

_
1000s of Sexy Singles online now at Lavalife - Click here 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D22031&_t=751140432&_m=EXT

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Books

2006-05-03 Thread John Connors
G'day,

I know this is a difficult question to answer because it's probably more a 
matter of personal taste than anything else.

I'm retired so money has to be watched fairly carefully and books are kind 
of expensive down here in Australia but the Mrs has said I can lash out on a 
book for my birthday. So I was wondering (bearing in mimd that I'm only 2 or 
3 steps above total beginner), what is the one book on python that I 
shouldn't be without?

John

_
realestate.com.au: the biggest address in property   
http://ninemsn.realestate.com.au

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Not Really Questions

2006-06-04 Thread John Connors
G'day,

While the list is kind of slow I thought I'd post a few thoughts on a couple 
of things in Python that bug me. They're not really questions but maybe 
someone can help me understand.

The first one is lists... I can't for the life of me understand why a list 
starts at zero. In everything else in life other than programming the 1st 
item in a list is always 1.

The next thing I don't understand is why the last number in a range is not 
used...

For a in range(1,6):
print a,

1 2 3 4 5

Once again it defies the logic of everything else we are taught in life.

The 3rd whinge is object oriented programming. I think I understand the 
principle behind OOP but in practise, to me, it just makes programs jumbled, 
unreadable and bloated. Just about every summary I have read on Python says 
it is designed to have a simple syntax and is easy to learn. As a beginner I 
can look at Python code and have a very good idea of what is happening and 
why unless it's written in OOP style in which case I have no idea.

John

_
Read, write and reply to Hotmail on your mobile. Find out more. 
http://mobilecentral.ninemsn.com.au/mcmobileHotmail/home.aspx

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor