Gary Herron schreef:
Mensanator wrote:
On Nov 7, 7:17 pm, Peng Yu pengyu...@gmail.com wrote:
It seems that int() does not convert '1e7'.
Because 'e' isn't a valid character in base 10.
But 1e7 is a valid float, so this works:
int(float('1e7'))
1000
That has a
Just a curiosity, why does Python do this?
l = [(base, int('1e7', base=base)) for base in range(15,37)]
l
[(15, 442), (16, 487), (17, 534), (18, 583), (19, 634), (20, 687),
(21, 742), (22, 799), (23, 858), (24, 919), (25, 982), (26, 1047),
(27, 1114), (28, 1183), (29, 1254), (30, 1327), (31,
Thomas wrote:
Just a curiosity, why does Python do this?
[(base, int('1e7', base=base)) for base in range(15,37)]
[(15, 442), (16, 487), (17, 534), (18, 583), (19, 634), (20, 687),
(21, 742), (22, 799), (23, 858), (24, 919), (25, 982), (26, 1047),
(27, 1114), (28, 1183), (29, 1254), (30,
On Nov 7, 7:17 pm, Peng Yu pengyu...@gmail.com wrote:
It seems that int() does not convert '1e7'.
Because 'e' isn't a valid character in base 10.
I'm wondering what
function to use to convert '1e7' to an integer?
int('1e7')
int(1e7)
1000
Traceback (most recent call last):
File
Peng Yu wrote:
It seems that int() does not convert '1e7'.
It seems it does, though:
int('1e7', base=16)
487
Mick.
--
http://mail.python.org/mailman/listinfo/python-list
Peng Yu wrote:
It seems that int() does not convert '1e7'. I'm wondering what
function to use to convert '1e7' to an integer?
int('1e7')
Traceback (most recent call last):
File stdin, line 1, in module
ValueError: invalid literal for int() with base 10: '1e7'
In Python the e-form
Mick Krippendorf mad.m...@gmx.de writes:
Peng Yu wrote:
It seems that int() does not convert '1e7'.
It seems it does, though:
int('1e7', base=16)
487
Well played, sir.
--
\ “It is wrong to think that the task of physics is to find out |
`\ how nature *is*. Physics
Mensanator wrote:
On Nov 7, 7:17 pm, Peng Yu pengyu...@gmail.com wrote:
It seems that int() does not convert '1e7'.
Because 'e' isn't a valid character in base 10.
But 1e7 is a valid float, so this works:
int(float('1e7'))
1000
That has a problem though, if you surpass the
On Sat, Nov 7, 2009 at 8:17 PM, Peng Yu pengyu...@gmail.com wrote:
It seems that int() does not convert '1e7'. I'm wondering what
function to use to convert '1e7' to an integer?
int('1e7')
Traceback (most recent call last):
File stdin, line 1, in module
ValueError: invalid literal for
Peng Yu wrote:
It seems that int() does not convert '1e7'. I'm wondering what
function to use to convert '1e7' to an integer?
1e7 is a way to express a float in science and math. Try float(1e7)
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Mick Krippendorf wrote:
Peng Yu wrote:
It seems that int() does not convert '1e7'.
It seems it does, though:
int('1e7', base=16)
487
Bah...so narrow-minded ;-)
print '\n'.join(Base %i: %i % (base, int('1e7',
base=base)) for base in range(15,37))
Base 15: 442
Base 16: 487
Base 17: 534
11 matches
Mail list logo