Re: [Tutor] Regular expressions

2014-02-15 Thread Santosh Kumar
Thank you all. On Thu, Feb 13, 2014 at 10:47 PM, Walter Prins wrote: > Hi, > > On 13 February 2014 06:44, Santosh Kumar wrote: > > I am using ipython. > > > > 1 ) Defined a string. > > > > In [88]: print string > > foo foobar > > > > 2) compiled the string to grab the "foo" word. > > > > In [8

Re: [Tutor] Beginner - understanding randint arguments

2014-02-15 Thread Steven D'Aprano
On Sat, Feb 15, 2014 at 04:25:34PM +, Marc Eymard wrote: > Can somebody explain why both low_range and high_range are still > returning their initial values ? Because you haven't changed either of them. Imagine the chaos if every time you did arithmetic on a variable, Python changed the var

Re: [Tutor] Beginner - understanding randint arguments

2014-02-15 Thread Alan Gauld
On 15/02/14 16:25, Marc Eymard wrote: Here is what happens in my script: >>> import random >>> low_range = -1 >>> high_range = 101 >>> random.randint(low_range + 1, high_range - 1) 56 >>> low_range -1 >>> high_range 101* I was rather expecting:

Re: [Tutor] Beginner - understanding randint arguments

2014-02-15 Thread Jay Lozier
On 02/15/2014 11:25 AM, Marc Eymard wrote: Hello Tutor, I need to generate a random integer between 0 and 100. The range is supposed to be adjusted by my two variables: low_range and high_range. The logic of using the variables as part of the function arguments is to manage to get a smaller

[Tutor] Beginner - understanding randint arguments

2014-02-15 Thread Marc Eymard
Hello Tutor, I need to generate a random integer between 0 and 100. The range is supposed to be adjusted by my two variables: low_range and high_range. The logic of using the variables as part of the function arguments is to manage to get a smaller range each time the function is called excludi

Re: [Tutor] thanks - Beginner - explaining 'Flip a coin' bug

2014-02-15 Thread Marc Eymard
Hi David, Thanks for your input about the logic of this little script of mine. I confess I omitted the edge possibility and assumed heads or taisl only. As I progress further with getting the foundation knowledge of the language itself, it is really appreciated to be corrected on what good prog

Re: [Tutor] Need help with generators....

2014-02-15 Thread Alan Gauld
On 15/02/14 13:35, Bunny Sehgal wrote: I am doing "Building Skills in Python". In the Generator Function example at I assume you are talking about this one: spins = [('red', '18'), ('black', '13'), ('red', '7'), ('red', '5'), ('black', '13'), ('red', '25'), ('red', '9'), ('black', '26'

[Tutor] Need help with generators....

2014-02-15 Thread Bunny Sehgal
I am doing "Building Skills in Python". In the Generator Function example at [url] http://www.itmaybeahack.com/homepage/books/python/html/p02/p02c08_generators.html#generator-function-example[/url]i can't understand, how it is working properly. what i understood is as follows:> 1)First it makes cou