Re: [Tutor] challenge-chapter 2

2013-05-24 Thread Steven D'Aprano
On 25/05/13 09:41, bob gailer wrote: On 5/22/2013 1:02 AM, Andrew Triplett wrote: ... illegal variable names ... That is a very poor description. Something can either be used as a variable name or not. abc can be used as a variable name, if can't. But it can be used as a variable name in so

Re: [Tutor] challenge-chapter 2

2013-05-24 Thread bob gailer
On 5/22/2013 1:02 AM, Andrew Triplett wrote: ... illegal variable names ... That is a very poor description. Something can either be used as a variable name or not. abc can be used as a variable name, if can't. I defy you to give me a variable name that is illegal! Anything you attempt to gi

Re: [Tutor] challenge-chapter 2

2013-05-22 Thread Evans Anyokwu
Hi Andrew, I'm sure the exercises at the end of the each chapters are there for you to attempt. Asking for help here without attempting it is not the best way to learn. If however, you've tried something - and it didn't work, by all means ask for help. In the mean time show us what you have so fa

Re: [Tutor] challenge-chapter 2

2013-05-22 Thread Matthew Ngaha
On Wed, May 22, 2013 at 6:02 AM, Andrew Triplett wrote: > I am on chapter two for Python Programming working on the challenges and the > question is: > > 1. Create a list of legal and illegal variable names. Describe why each is > either legal or illegal. Next, create a list of "good" and "bad" le

Re: [Tutor] challenge-chapter 2

2013-05-22 Thread Peter Otten
Andrew Triplett wrote: > I am on chapter two for Python Programming working on the challenges and > the question is: > > 1. Create a list of legal and illegal variable names. Describe why each is > either legal or illegal. Next, create a list of "good" and "bad" legal > variable names. Describe w

Re: [Tutor] Challenge

2009-09-22 Thread Tim Bowden
On Tue, 2009-09-22 at 05:13 -0700, Ali Sina wrote: > Hello tutor > > I downloaded a guide about learning Python by Michael Dawson which has > challenges at the end of each chapter. I'm a novice so I encountered a > problem with this challenge: > > > > "Write a program that flips a coin 100 time

Re: [Tutor] Challenge

2009-09-22 Thread Daniel Sarmiento
Date: Tue, 22 Sep 2009 05:13:32 -0700 (PDT) From: Ali Sina To: tutor@python.org Subject: [Tutor] Challenge Message-ID: <826729.63168...@web45911.mail.sp1.yahoo.com> Content-Type: text/plain; charset="iso-8859-1" Hello tutor I downloaded a guide about learning Python by Michael Dawson which ha

Re: [Tutor] Challenge

2009-09-22 Thread Che M
> I wrote this code but I know its wrong. Although it works properly: > flips=0 > h='heads' > t='tails' > while True: >flips+=1 >if flips>100: >break >if True: >print(flips,'=',h or t) > But it prints every number with the string 'heads'. I'm really blank at this. It

Re: [Tutor] Challenge

2009-09-22 Thread Alan Gauld
Ali Sina wrote: I wrote this code but I know its wrong. Although it works properly: Thereis adfference between "works properly" (ie does what it should) and "runs without errors" :-) You need to read up a bit more on boolean expressions flips=0 h='heads' t='tails' while True: flips+=1

Re: [Tutor] Challenge

2009-09-22 Thread Eric Walker
Ali, I am new at this but here is my interpretation. 1) flip coin 100 times, and print out the number of heads and number of tails. from random import Random score = [0,0]# first position will be heads and second position will be tails count=0#counter to find out how many times we have flipped. a

Re: [Tutor] Challenge

2009-09-22 Thread Lucas Prado Melo
On Tue, Sep 22, 2009 at 9:13 AM, Ali Sina wrote: > But it prints every number with the string 'heads'. I'm really blank at > this. It may have something to do with the 'random' module. > > You could use the choice function on random. Given a list, the choice function returns a random element of

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"Kent Johnson" wrote > We can fake the Delphi style by using a default constructor and then > just > calling the "constructors" after initialisation: > But its two lines not one... :-( Why not this? class C: def __init__(self): pass @staticmethod def LoadFromFile(fname, count): c

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"Kent Johnson" wrote But its two lines not one... :-( Why not this? class C: def __init__(self): pass @staticmethod def LoadFromFile(fname, count): c = C() # init c from the file return c and similar for Create(). Client code is one line: c = C.LoadFromFile(fn, cnt) Kent

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 3:55 PM, Alan Gauld wrote: > > "W W" wrote > >> class C: >>> @constructor >>> def LoadFromFile(fname, count): ... >>> @constructor >>> def Create(valueTuple):... >>> >>> Personally I prefer the Delphi style sincve it makes the constructor >>> call explicit and adds

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Kent Johnson
On Mon, Jun 1, 2009 at 4:55 PM, Alan Gauld wrote: > We can fake the Delphi style by using a default constructor and then just > calling the "constructors" after initialisation: > > class C: >        def __init__(): pass >       @constructor >       def LoadFromFile(fname, count): ... >     �...@c

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"W W" wrote class C: @constructor def LoadFromFile(fname, count): ... @constructor def Create(valueTuple):... Personally I prefer the Delphi style sincve it makes the constructor call explicit and adds to the documentation. Alan G That does make it problematic... although I sup

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 8:59 AM, Alan Gauld wrote: > > "W W" wrote > > ( Multiple constructors (or factory methods) is one feature I would like >>> to see added to Python! ) >>> >> >> Wouldn't it be possible to create sort of a... bastardization? i.e. >> >> def __init__(self, *args): >> if len

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Michael H . Goldwasser
Chris, Thanks for your well-written reply. Your analogy to the complexities of other special methods is well noted. I'll accept the "small price for flexibility" that you note, if necessary. However, I still desire a cleaner solution. I can examine the inherited slots to see which sp

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"W W" wrote ( Multiple constructors (or factory methods) is one feature I would like to see added to Python! ) Wouldn't it be possible to create sort of a... bastardization? i.e. def __init__(self, *args): if len(args) == 0: #do something if len(args) == 1: #do somethin

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 2:27 AM, Alan Gauld wrote: > > "Kent Johnson" wrote > >> > Yesterday, I posted a question to python-list involving custom >> > deepcopies in an inheritance hierarchy. I haven't received any >> >> ISTM that in general B.__deepcopy__() should call A.__deepcopy__() to do >> th

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"Kent Johnson" wrote > Yesterday, I posted a question to python-list involving custom > deepcopies in an inheritance hierarchy. I haven't received any ISTM that in general B.__deepcopy__() should call A.__deepcopy__() to do the "A" part of the work. In your example, this won't work because

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-05-31 Thread Kent Johnson
On Sun, May 31, 2009 at 5:35 PM, Michael H. Goldwasser wrote: > > Yesterday, I posted a question to python-list involving custom > deepcopies in an inheritance hierarchy.  I haven't received any > responses, so I thought I'd cross-post to see if anyone on tutor > has any thoughts. > > To avoid spl

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-30 Thread Nathan Pinno
Lisa and all,   I got rid of that portion of my site. All that's there now is the e-book publishing part of my site.   Nathan Pinno - Original Message - From: Lisa Fukui To: Nathan Pinno Sent: Friday, September 30, 2005 11:22 AM Subject: Re: [Tutor] Challenge [w

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-27 Thread Adam
Original Message - From: Adam To: Nathan Pinno Cc: bob ; tutor@python.org Sent: Monday, September 26, 2005 3:37 PM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] Can I have a look at the password program by any chance? Tutor

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-27 Thread Adam
Cc: bob ; tutor@python.org Sent: Monday, September 26, 2005 3:37 PM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] Can I have a look at the password program by any chance? Tutor maillist  -   Tutor@python.org http://mail.python.org/m

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-26 Thread bob
At 10:56 AM 9/26/2005, Nathan Pinno wrote: The actual URL is http://zoffee.tripod.com/purchasecompprogs.htm I did what you suggested. Take another look, and tell me if you were a potential customer, would you purchase something? No. For one thing I can (if I didn't already have one) buy a "re

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-26 Thread Adam
Can I have a look at the password program by any chance? Tutor maillist  -   Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-26 Thread Nathan Pinno
The actual URL is http://zoffee.tripod.com/purchasecompprogs.htm - Original Message - From: bob To: Nathan Pinno Cc: tutor@python.org Sent: Monday, September 26, 2005 11:54 AM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] At

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-26 Thread bob
he page or the file that you're looking for is not here.   Why not take the challenge? It's not like I'm asking much.   Nathan Pinno - Original Message - From: bob To: Nathan Pinno Cc: tutor@python.org Sent: Thursday, September 22, 2005 10:08 PM Subject: Re: [Tuto

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-26 Thread Nathan Pinno
Cc: tutor@python.org Sent: Thursday, September 22, 2005 10:08 PM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] At 06:42 PM 9/22/2005, Nathan Pinno wrote: The URL is http://zoffee.tripod.com/purchasecomprogs.htm[snip]At your invitation I visited the site. I p

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-22 Thread Poor Yorick
bob wrote: > At 06:42 PM 9/22/2005, Nathan Pinno wrote: > >> The URL is http://zoffee.tripod.com/purchasecomprogs.htm > > > [snip] > > At your invitation I visited the site. I personally would not purchase > anything listed there due to insufficient information. I don't know what > I'm gettin

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-22 Thread bob
At 06:42 PM 9/22/2005, Nathan Pinno wrote: The URL is http://zoffee.tripod.com/purchasecomprogs.htm [snip] At your invitation I visited the site. I personally would not purchase anything listed there due to insufficient information. I don't know what I'm getting! I suggest you dedicate a page to

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-22 Thread Nathan Pinno
riginal Message - From: Adam To: Nathan Pinno Sent: Thursday, September 22, 2005 5:21 AM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] What's the URL? On 22/09/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: I have a challenge

Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]

2005-09-22 Thread Nathan Pinno
  http://zoffee.tripod.com/purchasecompprogs.htm is the URL. - Original Message - From: Adam To: Nathan Pinno Sent: Thursday, September 22, 2005 5:21 AM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] What's the URL? O