R
redstone-cold
I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ?
I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ?
I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ?
I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ?
This is a non-question. The input is the same, the output is the same,
what else matters?
On the other hand, if you want to dig deeper, there are lots of differences:
1) the former has a shorter source file
2) different C code is utilized inside the interpreter
3) different machine code executes
4) the temporary objects created have different id's and types
5) different execution times (by a trivial amount)
6) it takes different keystrokes to edit the two source files once you
want to make it do something useful
7) the processor works a little harder on one than the other, possibly
resulting in a different power consumption
8) different byte code is produced
Or you could be asking about Python version 3, in which case
1) the syntax error message points to a different character
This is a non-question. The input is the same, the output is the same,
what else matters?
On the other hand, if you want to dig deeper, there are lots of differences:
1) the former has a shorter source file
2) different C code is utilized inside the interpreter
3) different machine code executes
4) the temporary objects created have different id's and types
5) different execution times (by a trivial amount)
6) it takes different keystrokes to edit the two source files once you
want to make it do something useful
7) the processor works a little harder on one than the other, possibly
resulting in a different power consumption
8) different byte code is produced
Or you could be asking about Python version 3, in which case
1) the syntax error message points to a different character
This is a non-question. The input is the same, the output is the same,
what else matters?
On the other hand, if you want to dig deeper, there are lots of differences:
1) the former has a shorter source file
2) different C code is utilized inside the interpreter
3) different machine code executes
4) the temporary objects created have different id's and types
5) different execution times (by a trivial amount)
6) it takes different keystrokes to edit the two source files once you
want to make it do something useful
7) the processor works a little harder on one than the other, possibly
resulting in a different power consumption
8) different byte code is produced
Or you could be asking about Python version 3, in which case
1) the syntax error message points to a different character
This is a non-question. The input is the same, the output is the same,
what else matters?
On the other hand, if you want to dig deeper, there are lots of differences:
1) the former has a shorter source file
2) different C code is utilized inside the interpreter
3) different machine code executes
4) the temporary objects created have different id's and types
5) different execution times (by a trivial amount)
6) it takes different keystrokes to edit the two source files once you
want to make it do something useful
7) the processor works a little harder on one than the other, possibly
resulting in a different power consumption
8) different byte code is produced
Or you could be asking about Python version 3, in which case
1) the syntax error message points to a different character
在 2012å¹´3月26日星期一UTC+8下åˆ8æ—¶11分03秒,Dave Angel写é“:
Oh ,God !
I know the print statement produces the same result when both of
these two instructions are executed ,I just want to know Is there any
difference between print 3 and print '3' in Python ?
3 '3' [3, '3']print(repr(3), repr('3'), [3, '3'])
I know the print statement produces the same result when both of these two
instructions are executed ,I just want to know Is there any difference
between print 3 and print '3' in Python ?
This is a non-question. The input is the same, the output is the same,
what else matters?
def fib1(n):
if n == 0: return 0
elif n == 1: return 1
f2, f1 = 0, 1
for _ in range(2, n+1):
f2, f1 = f1, f2 + f1
return f1
def fib2(n):
if n == 0: return 0
elif n == 1: return 1
else: return fib2(n-1) + fib2(n-2)
Try calling fib1(35) and fib2(35). Still think only the input and output
matter?
For the record, fib2(35) ends up making a total of 29860703 function
calls, compared to 35 iterations for fib1.
I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ?
在 2012å¹´3月26日星期一UTC+8下åˆ7æ—¶45分26秒,iMath写é“:
thx everyone
Here's a future import though I used,so I can use the planned 3 with a 2x
python version in the command line interpreter:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\david>c:\python26\python.exe
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
on
win32
Type "help", "copyright", "credits" or "license" for more information.
C:\Users\david>c:\python27_64\python.exe
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]on
win
32
Type "help", "copyright", "credits" or "license" for more information.
In other words type(value), and find out the difference.
On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote <[email protected]
On 09/09/12 14:23, iMath wrote:
在 2012å¹´3月26日星期一UTC+8下åˆ7æ—¶45分26秒,__iMath写é“:
I know the print statement produces the same result when
both of these two instructions are executed ,I just want to
know Is there any difference between print 3 and print '3'
in Python ?
thx everyone
Here's a future import though I used,so I can use the planned 3 with a
2x python version in the command line interpreter:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\david>c:\python26\python.exe
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
C:\Users\david>c:\python27_64\python.exe
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit
(AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
In other words type(value), and find out the difference.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.