i have a program that will print out large amounts of numbers in separate groups, how can i get python to tell me which set of numbers is the largest, is there a built in type i can enter to display the size of what has been printed in the shell, for example one set of numbers is 2 4 5 6 7 11 23 45 67 and another is 1 3 5 7 9 13 14 16 17 19 23 24 27 34 36 28, obviously the second set has more numbers, but to loook through thousands of these would be crazy, i need to find the largest set of numbers
python counting large numbers
Page 1 of 13 Replies - 1390 Views - Last Post: 14 September 2010 - 06:45 PM
Replies To: python counting large numbers
#2
Re: python counting large numbers
Posted 31 August 2010 - 09:55 PM
If this is a set you can use the
Or if the data is in another form, like a list say you could simply use the
code.
PySet_Size(Documentation)
Or if the data is in another form, like a list say you could simply use the
len(list)
code.
#3
Re: python counting large numbers
Posted 01 September 2010 - 08:12 AM
To find the maximum of a list of numbers, you need the max function.
For example:
You need to store the size of the list of numbers as you are going rather than attempting to read the numbers from the shell.
You could use a list:
Hope this helps
For example:
>>> max([1, 2, 3, 4, 5]) 5 >>> max([10, 13, 9, 11, 12]) 13
You need to store the size of the list of numbers as you are going rather than attempting to read the numbers from the shell.
You could use a list:
#At the beginning of the code, outside the number processing function. lengthOfNumberLists = [] # Put this at the end of processing a single list of numbers # len(x) determines the length of a list lengthOfNumberLists.append(len(List1)) #Then to determine the longest list max(lengthOfNumberList)
Hope this helps
This post has been edited by Simown: 01 September 2010 - 08:14 AM
#4
Re: python counting large numbers
Posted 14 September 2010 - 06:45 PM
thanx that was what i ended up using.....the max
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|