Re: [Tutor] Python Variable Addition

2012-04-30 Thread Mark Lawrence
On 01/05/2012 00:35, Steven D'Aprano wrote: Mark Lawrence wrote: On 30/04/2012 19:40, Alan Gauld wrote: But if the number of spaces is critical string formatting is better still. And better than string addition. True indeed, but which of the three versions of string formatting that I'm awa

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Steven D'Aprano
Mark Lawrence wrote: On 30/04/2012 19:40, Alan Gauld wrote: But if the number of spaces is critical string formatting is better still. And better than string addition. True indeed, but which of the three versions of string formatting that I'm aware of? Any of them. -- Steven __

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Mark Lawrence
On 30/04/2012 19:40, Alan Gauld wrote: On 30/04/12 19:27, Mark Lawrence wrote: print 'Addition of above two numbers are : ', z Except that you'll get two spaces after the colon :) OK thats true, Try this: print 'Addition of above two numbers are :', z for one. :-) But if the number of sp

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Alan Gauld
On 30/04/12 19:27, Mark Lawrence wrote: print 'Addition of above two numbers are : ', z Except that you'll get two spaces after the colon :) OK thats true, Try this: print 'Addition of above two numbers are :', z for one. :-) But if the number of spaces is critical string formatting is be

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Mark Lawrence
On 30/04/2012 18:36, Alan Gauld wrote: On 30/04/12 11:00, Kapil Shukla कपिल शुक्‍ला wrote: Viral You should be doing this "Addition of two numbers is" + str(x+y) There is no need for str() since print implicitly calls string to convert objects to string format. Also the addition is not needed

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Alan Gauld
On 30/04/12 11:00, Kapil Shukla कपिल शुक्‍ला wrote: Viral You should be doing this "Addition of two numbers is" + str(x+y) There is no need for str() since print implicitly calls string to convert objects to string format. Also the addition is not needed since print takes a comma separated l

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Dave Angel
On 04/30/2012 05:50 AM, viral shah wrote: > Hi > > I'm new in the learning of python > > I want to make simple code for two variable addition > > Please help me in the following code > > *x = 12 > print x > y =20 > print y > z = x+y > print 'Addition of above two numbers are : ' + int.z > * > when

Re: [Tutor] Python Variable Addition

2012-04-30 Thread Kapil Shukla कपिल शुक्‍ला
rom: viral shah Sender: tutor-bounces+shukla.kapil=gmail@python.org Date: Mon, 30 Apr 2012 15:20:21 To: Subject: [Tutor] Python Variable Addition ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.

[Tutor] Python Variable Addition

2012-04-30 Thread viral shah
Hi I'm new in the learning of python I want to make simple code for two variable addition Please help me in the following code *x = 12 print x y =20 print y z = x+y print 'Addition of above two numbers are : ' + int.z * when I run this same I got an error message : *AttributeError: type object