Re: [Tutor] Regular expressions

2014-02-12 Thread Peter Otten
Santosh Kumar wrote: > Hi all, > > I am using ipython. > > 1 ) Defined a string. > > In [88]: print string > foo foobar > > 2) compiled the string to grab the "foo" word. > > In [89]: reg = re.compile("foo",re.IGNORECASE) > > 3) Now i am trying to match . > > In [90]: match = reg.match(stri

[Tutor] Regular expressions

2014-02-12 Thread Santosh Kumar
Hi all, I am using ipython. 1 ) Defined a string. In [88]: print string foo foobar 2) compiled the string to grab the "foo" word. In [89]: reg = re.compile("foo",re.IGNORECASE) 3) Now i am trying to match . In [90]: match = reg.match(string) 4) Now i print it. In [93]: print match.group()

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

2014-02-12 Thread Steven D'Aprano
On Thu, Feb 13, 2014 at 10:25:04AM +1100, Steven D'Aprano wrote: > On Wed, Feb 12, 2014 at 05:26:26PM -0500, Dave Angel wrote: > > The nntp news system tossed the attachments, I believe. > > If you check out the gmane.comp.python.tutor mirror, you will see the > attachments. Er, that is to say

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

2014-02-12 Thread Steven D'Aprano
On Wed, Feb 12, 2014 at 05:26:26PM -0500, Dave Angel wrote: > He posted in html and included two attachments. His email program > added added a text version, which we know is frequently bogus. "Frequently?" I don't think so. I hardly ever see text parts which don't say the same thing as the ht

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

2014-02-12 Thread Steven D'Aprano
On Wed, Feb 12, 2014 at 10:31:51PM +0100, spir wrote: > On 02/12/2014 10:14 PM, Steven D'Aprano wrote: > >The first thing to notice is that by the logic of the task, each flip > >must be either a Head or a Tail, so the number of Heads and the number > >of Tails should always add up to the number o

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

2014-02-12 Thread Steven D'Aprano
On Wed, Feb 12, 2014 at 09:30:22PM +, Neil Cerutti wrote: > > Perhaps it is time for you to give up on whatever tool you are > > using to read this mailing list, or at least to change your > > assumption when you see a contentless message from "Original > > poster didn't send email" to "I can'

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

2014-02-12 Thread Dave Angel
Steven D'Aprano Wrote in message: > On Wed, Feb 12, 2014 at 02:08:17PM -0500, Dave Angel wrote: >> Marc Eymard Wrote in message: >> > ___ >> > Tutor maillist - Tutor@python.org >> > To unsubscribe or change subscription options: >> > https://mail.py

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

2014-02-12 Thread spir
On 02/12/2014 10:14 PM, Steven D'Aprano wrote: On Wed, Feb 12, 2014 at 03:25:22PM +, Marc Eymard wrote: I want to emulate a coin flip and count how many heads and tails when flipping it a hundred times. In my last reply, I said I'd next give you some pointers to improve the code. If you'

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

2014-02-12 Thread Neil Cerutti
On 2014-02-12, Steven D'Aprano wrote: > On Wed, Feb 12, 2014 at 02:08:17PM -0500, Dave Angel wrote: >> Next time please post in text form rather than html, and >> actually include the code you're asking us to comment on. > > Dave, your tools are letting you down. Marc did post in text, and did >

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

2014-02-12 Thread Steven D'Aprano
On Wed, Feb 12, 2014 at 03:25:22PM +, Marc Eymard wrote: > I want to emulate a coin flip and count how many heads and tails when > flipping it a hundred times. In my last reply, I said I'd next give you some pointers to improve the code. If you'd rather work on it yourself first, stop rea

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

2014-02-12 Thread Steven D'Aprano
On Wed, Feb 12, 2014 at 03:25:22PM +, Marc Eymard wrote: > However, I still don't understand the bug since, in my understanding, > both files are incrementing variable count_flips each time until the > loop becomes false. The problem with the "wrong" file is that it increments the count_fla

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

2014-02-12 Thread R. Alan Monroe
> When running it, either returned values are wrong or the script > seems to enter in an infinite loop showing no return values at all. One other tip: "for" loops are usually more practical when you know exactly how many times you want to loop (100 coin flips). "while" loops are usually more prac

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

2014-02-12 Thread Steven D'Aprano
On Wed, Feb 12, 2014 at 02:08:17PM -0500, Dave Angel wrote: > Marc Eymard Wrote in message: > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > > Next

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

2014-02-12 Thread Zachary Ware
Hi Marc, On Wed, Feb 12, 2014 at 9:25 AM, Marc Eymard wrote: > Hello there, > > I want to emulate a coin flip and count how many heads and tails when > flipping it a hundred times. > > I first coded coinflip_WRONG.py with "count_flips += 1" statement within the > if/else block. > When running it,

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

2014-02-12 Thread Alan Gauld
On 12/02/14 15:25, Marc Eymard wrote: However, I still don't understand the bug since, in my understanding, both files are incrementing variable *count_flips* each time until the loop becomes false. > count_heads = 0 > count_tails = 0 > count_flips = 0 > > while count_flips != 100: This is usu

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

2014-02-12 Thread Dave Angel
Marc Eymard Wrote in message: > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > Next time please post in text form rather than html, and actually include the

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

2014-02-12 Thread R. Alan Monroe
> Can somebody explain the reason of the bug. I think you have an indentation goof on line 24 in the "wrong" version (the else clause). Alan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org

[Tutor] Beginner - explaining 'Flip a coin' bug

2014-02-12 Thread Marc Eymard
Hello there, I want to emulate a coin flip and count how many heads and tails when flipping it a hundred times. I first coded coinflip_WRONG.py with "count_flips += 1" statement within the if/else block. When running it, either returned values are wrong or the script seems to enter in an infin

Re: [Tutor] Better flow for this?

2014-02-12 Thread R. Alan Monroe
> You keep taking turns until you get home or die. Each turn has 4 > phases. > while playing: > #phase 1 - fly every turn, you might die > #phase 2 - stuff shoots at you every turn, you might die > #phase 3 - may or may not get an event card, with certain cards you might > die > #

Re: [Tutor] Recommendation For A Complete Noob

2014-02-12 Thread Matthew Ngaha
> Hi, > > I'm completely new to programming in general and everything I have read so > far has pointed me to Python. I was just hoping to get some input as to where > I might start. > Start with Python programming for the absolute beginner Great author. The book gives you lots of exercises a

Re: [Tutor] Better flow for this?

2014-02-12 Thread R. Alan Monroe
> Also explain the logic in plain words. Else, we can only guess. Were the comments not enough? You keep taking turns until you get home or die. Each turn has 4 phases. while playing: #phase 1 - fly every turn, you might die #phase 2 - stuff shoots at you every turn, you might die #ph

Re: [Tutor] Recommendation For A Complete Noob

2014-02-12 Thread Russel Winder
On Tue, 2014-02-11 at 23:25 +, Bob Williams wrote: […] > I'm also a noob. In addition to all the excellent recommendations > already posted, I would suggest setting yourself a task to solve in > python. It's far more interesting than working through the examples in > most books - the challenge

Re: [Tutor] Better flow for this?

2014-02-12 Thread spir
On 02/12/2014 10:51 AM, spir wrote: On 02/12/2014 03:06 AM, R. Alan Monroe wrote: I started on an implementation of a solitaire board game simulating a B52 bombing run ( http://victorypointgames.com/details.php?prodId=119 ). It seems like there ought to be a better way to structure this program

Re: [Tutor] Better flow for this?

2014-02-12 Thread spir
On 02/12/2014 03:06 AM, R. Alan Monroe wrote: I started on an implementation of a solitaire board game simulating a B52 bombing run ( http://victorypointgames.com/details.php?prodId=119 ). It seems like there ought to be a better way to structure this program flow, but it's escaping me at the mom

Re: [Tutor] Recommendation For A Complete Noob

2014-02-12 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/02/14 00:58, Dave Angel wrote: > Bob Williams Wrote in message: > > >> to slice those lines to get the artist and album names into a >> list. >> >> So far, so good but my output contains duplicates, so my final >> task is to work out how to g