Re: [Tutor] __init__

2016-08-29 Thread Steven D'Aprano
On Mon, Aug 29, 2016 at 07:03:31PM +, monik...@netzero.net wrote: > > > Hi: > If __init__ is not defined in a class, will it be called when creating an > instance? Yes, because the default __init__ does nothing. So if you don't need an __init__, just don't bother to write it! Try experimen

Re: [Tutor] super

2016-08-29 Thread Steven D'Aprano
On Mon, Aug 29, 2016 at 09:18:17PM +, monik...@netzero.net wrote: > Hi: > Why in super(Child,self).setVal(value) there is Child and self in super? Why > the repetition? Or should it say Parent instead of Child? > In my understanding it should say Parent2 instead of Child since it refers to >

Re: [Tutor] __init__

2016-08-29 Thread Joel Goldstick
On Mon, Aug 29, 2016 at 3:03 PM, monik...@netzero.net wrote: > > > Hi: > If __init__ is not defined in a class, will it be called when creating an > instance? > What in a case if this class inherits from parent with __init__ and without > __init__? > Thank you > Monika >

Re: [Tutor] __init__

2016-08-29 Thread Alan Gauld via Tutor
On 29/08/16 20:03, monik...@netzero.net wrote: If __init__ is not defined in a class, will it be called when creating an instance? What in a case if this class inherits from parent with __init__ and without __init__? The easiest way to find out is try it and see what happens! Just put appro

[Tutor] super

2016-08-29 Thread monik...@netzero.net
Hi: Why in super(Child,self).setVal(value) there is Child and self in super? Why the repetition? Or should it say Parent instead of Child? In my understanding it should say Parent2 instead of Child since it refers to which parent to take the medthod from. In case of multiple inheritance it shoul

[Tutor] __init__

2016-08-29 Thread monik...@netzero.net
Hi: If __init__ is not defined in a class, will it be called when creating an instance? What in a case if this class inherits from parent with __init__ and without __init__? Thank you Monika www.theictm.org (Sponsored by Content.Ad) 1

Re: [Tutor] Problem

2016-08-29 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
The following code should do. for a in range(1,10): for b in range(1,5): for c in range(1,5): for mc in range(50, 55): if mc ==(6*a)+(9*b)+(20*c): print "mc= ",mc,"a= ",a,"b= ",b,"c=",c regards, Sarma. On Mon, Aug 29, 2016 at 3:34 PM, A

Re: [Tutor] Problem

2016-08-29 Thread Alan Gauld via Tutor
On 28/08/16 23:53, shahan khan wrote: I changed the code a bit and this is the result: for a in range(1,11): for b in range(1,6): for c in range(1,6): mc=(6*a)+(9*b)+(20*c) if mc==50: print 'For 50 McNuggets:''a=',a,'b=',b,'c=',c if mc==51: print 'Fpr 51 McNuggets:''a=',a,'b=',b,'c=',c if mc==52:

Re: [Tutor] Problem

2016-08-29 Thread zakaria
The " {} " is the place holder of the values of a, b and c argument passed to format. this example maybe can help to understand print('I like the python {}'.format('mailing-list')) will output >>>  I like the python mailing-list The format methode will substitute the {} with the argument it takes

Re: [Tutor] Problem

2016-08-29 Thread zakaria
if you print the values of a, b ,c that satisfy and don't satisfy the condiction cm == 50 at the same time, you can't know what works and what did not work. here is the code that i wrote and worked well for a in range(1, 11):         # i replaced 10 by 11 to include the 10      for b in range(1,

Re: [Tutor] Problem

2016-08-29 Thread Shahan Khan
I understand your argument. You're saying M(50),M(51)and M(52) is basically a set of 6 9 and 20 packs and we should approach it by using lower values starting from 0 for one or two variables to simply the solution on paper. I think I have some idea now as to how to approach this problem. Sent f

Re: [Tutor] Problem

2016-08-29 Thread khalil zakaria Zemmoura
Can you please rewrite the python code using proper indentation, since, as you know, indentation matters in Python Le 28 août 2016 18:40, "shahan khan" a écrit : Hello I'm teching myself Python using MIT opencourse ware. I'm a beginner and have some what knowledge of c and c++. I'm using Python

Re: [Tutor] Problem

2016-08-29 Thread shahan khan
Yes i format my code but i can't figure out this new problem On Mon, Aug 29, 2016 at 3:20 AM, Joel Goldstick wrote: > On Sun, Aug 28, 2016 at 10:46 AM, shahan khan > wrote: > > Hello > > I'm teching myself Python using MIT opencourse ware. I'm a beginner and > > have some what knowledge of c an

Re: [Tutor] Problem

2016-08-29 Thread shahan khan
I changed the code a bit and this is the result: for a in range(1,11): for b in range(1,6): for c in range(1,6): mc=(6*a)+(9*b)+(20*c) if mc==50: print 'For 50 McNuggets:''a=',a,'b=',b,'c=',c if mc==51: print 'Fpr 51 McNuggets:''a=',a,'b=',b,'c=',c if mc==52: print 'For 52 McNuggets:''a=',a,'b=',b,

Re: [Tutor] Problem

2016-08-29 Thread Shahan Khan
Thankyou so much for taking the time it really means alot. I'll change the code and try again. I have just one question what purpose does " {} " serve here? Sent from my iPhone > On 29-Aug-2016, at 2:30 AM, zakaria wrote: > > if you print the values of a, b ,c that satisfy and don't satisfy th