arrays in python

Steve Holden steve at holdenweb.com
Fri Feb 10 18:23:17 EST 2006


Kermit Rose wrote:
> From: Kermit Rose
> Date: 02/10/06 17:36:34
> To: python-help at python.org
> Subject: Arrays
>  
>   
> Hello.
>  
> I want to write a program in python using integer arrays.
>  
> I wish to calculate formulas using 200 digit integers.
>  
> I could not find any documentation in python manual about declaring arrays.
>  
> I searched the internet
>  
> and found an example that said I must declare
>  
> from Numeric import *
>  
>  
> and I downloaded a numerical python  extension,
>  
> but still  have not found a way to declare an array of given length.
>  
> The zeros function always gives me an error message.
>  

No need to do anything special. Python allows long integers, and you can 
calculate directly with them:

  >>> big1 = int('1' + 100*'2')
  >>> big2 = int('2' + 100*'3')
  >>> big1
12222222222222222222222222222222222222222222222222222222222222222222222222222222
222222222222222222222L
  >>> big2
23333333333333333333333333333333333333333333333333333333333333333333333333333333
333333333333333333333L
  >>> big1 + big2
35555555555555555555555555555555555555555555555555555555555555555555555555555555
555555555555555555555L
  >>>

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list