Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49374
| Date | 2013-06-28 15:38 +0100 |
|---|---|
| Subject | ? get negative from prod(x) when x is positive integers |
| From | Vincent Davis <vincent@vincentdavis.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3958.1372430325.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
I have a list of a list of integers. The lists are long so i cant really
show an actual example of on of the lists, but I know that they contain
only the integers 1,2,3,4. so for example.
s2 = [[1,2,2,3,2,1,4,4],[2,4,3,2,3,1]]
I am calculating the product, sum, max, min.... of each list in s2 but I
get negative or 0 for the product for a lot of the lists. (I am doing this
in ipython)
for x in s2:
print('len = ', len(x), 'sum = ', sum(x), 'prod = ', prod(x), 'max = ',
max(x), 'min = ', min(x))
...
('len = ', 100, 'sum = ', 247, 'prod = ', 0, 'max = ', 4, 'min = ', 1)
('len = ', 100, 'sum = ', 230, 'prod = ', -4611686018427387904, 'max =
', 4, 'min = ', 1)
('len = ', 100, 'sum = ', 261, 'prod = ', 0, 'max = ', 4, 'min = ', 1)
.....
('prod =', 0, 'max =', 4, 'min =', 1)
('prod =', 1729382256910270464, 'max =', 4, 'min =', 1)
('prod =', 0, 'max =', 4, 'min =', 1)
....
Whats going on?
Vincent Davis
720-301-3003
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
? get negative from prod(x) when x is positive integers Vincent Davis <vincent@vincentdavis.net> - 2013-06-28 15:38 +0100
csiph-web