[Tutor] Starting over with Python

Andreas Kostyrka andreas at kostyrka.org
Thu Dec 14 07:21:44 CET 2006


* John Carmona <jeannot18 at hotmail.com> [061214 02:21]:
> After quite a while away from Python, I have decided to re-study Python. I 
> am interested to learn Python to support my love for Cryptography. I have a 
> first very easy question (did some search on Google but could not find 
> anything helpful). I realise that this is very basic so be gentle with me.
> 
> If i insert the following script:
> 
> -------------------------------------------------------------------------------------------------
> odd =1
> >>>while odd <=100:
> 	if (odd%2)==1:
> 		print odd
> 	odd = odd + 1
> -------------------------------------------------------------------------------------------------
> I get a list of the odd numbers from 1 to 99. But now if I wanted to add 
> those number together (i.e. 1 + 3 +5 + 7 etc.), what line of coding should I 
> include? I have tried to add "odd + odd" but it did not work. In advance 
> thanks.
> 
> If anyone could direct me to some site where python is associated with

www.python.org has a nice tutorial in the documentation section if  I
remember right. Well it had it in the early 90s :)

print range(1, 100, 2)
print sum(range(1, 100, 2))

Andreas


More information about the Tutor mailing list