473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

arrays in python

From: Kermit Rose
Date: 02/10/06 17:36:34
To: py*********@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.
Kermit < ke****@polaris.net >

Feb 10 '06 #1
3 4217
> I want to write a program in python using integer arrays.

you can :)

I wish to calculate formulas using 200 digit integers.
no problem
I could not find any documentation in python manual about declaring arrays.

I searched the internet
read here
http://diveintopython.org/native_data_types/lists.html

maybe list are what you are looking for
and found an example that said I must declare

from Numeric import *
yes, one can use Numeric for this taks too
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.

import Numeric as N, random as rand
nums = [33 ** rand.randint(10,100) for i in range(200)]
len(nums) 200 nums[0] 16664658128640303915417329756770834417490089065467 26522024522041932256405404932170047036994592860856 233379702595619607481259213235163454890913L
a = N.array(nums)
len(a) 200 a[0] 16664658128640303915417329756770834417490089065467 26522024522041932256405404932170047036994592860856 233379702595619607481259213235163454890913L

by the way, you know you can use interactive Python iterpreter
and there is dir and help function
dir(a) ['__copy__', '__deepcopy__', 'astype', 'byteswapped', 'copy',
'iscontiguous', 'itemsize', 'resize', 'savespace', 'spacesaver',
'tolist', 'toscalar', 'tostring', 'typecode'] dir(nums) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
'__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__',
'__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__',
'__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',
'__setslice__', '__str__', 'append', 'count', 'extend', 'index',
'insert', 'pop', 'remove', 'reverse', 'sort']


Regards, Daniel

Feb 10 '06 #2
On Fri, 10 Feb 2006 17:50:21 -0500, Kermit Rose wrote:
I want to write a program in python using integer arrays.

I wish to calculate formulas using 200 digit integers.
Must the integers have exactly 200 digits? If you multiply one of these
200-digit integers by ten, should it silently overflow, raise an
exception, or become a 201-digit integer?

[snip]
The zeros function always gives me an error message.


Oh, don't tell me, I love playing guessing games!

Is it a SyntaxError?

--
Steven.

Feb 11 '06 #3
> Oh, don't tell me, I love playing guessing games!

Don't you mean "No no... don't tell me. I'm keen to guess."

Sorry, I couldn't resist... :-)

(for those who just went huh?, see
http://www.aldo.com/sgt/CheeseShoppeSkit.htm)

Feb 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Simon Foster | last post by:
I have some code which attempts to convert Python arrays (tuples of tuples of tuples...) etc. into C arrays with equivalent contents. The prototype code is shown below. My only question is, is...
6
by: Rahul | last post by:
Hi. I just wanted to know why arrays have not been included as a builtin datatype like lists or dictionaries? The numpy extension shows that it can be implemented. then why not include arrays in...
11
by: Soeren Sonnenburg | last post by:
Hi all, Just having started with python, I feel that simple array operations '*' and '+' don't do multiplication/addition but instead extend/join an array: a= >>> b= >>> a+b
4
by: CC | last post by:
Hi there, I wanna compile a 6000x1000 array with python. The array starts from 'empty', each time I get a 6000 length list, I wanna add it to the exist array as a column vector. Is there any...
0
by: Frank | last post by:
Hi, I use rpy on linux to call R functions. Works fine up to the following problem: How to parse arrays (no vectors, that means 2-dimensional) to R without much effort? The following code...
11
by: Gordon C | last post by:
Absolute newbie here. In spite of the Python Software Foundation tutorial's ( http://www.python.org/doc/current/tut/tut.html ) use of the array declaration array(type), the Python interpreter does...
30
by: Ivan Reborin | last post by:
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For...
1
by: Fizzics | last post by:
This is my first post here at Bytes. I have been trolling it, mostly with the help of Google searches, for some time now. I have done about all of the searching and reading that I really know how to...
0
by: datapata | last post by:
Hi I have some C++ code that I need to access from Python. I don't need to access any classes or anything, just a couple of functions that take one array as input and produce another array as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.