hey guys is it possible 2 do so??? as in like i want 2 write numbers from 1 to 1000 in a file f.txt say.... using the while loop im stuck... as the indexing variable for incrementing the numbers to 1000 ITSELF gets printed if i use '' or "" or '\j' or "\j"...
also is there an easy way of converting this c++ code 2 a python code [without suing swig].... its basically arrays....
-
float a[6][6];
-
for(int i=0;i<5;i++)
-
{
-
a[2][2]=i;
-
a[4][3]=-i;
-
}
I can easily substitue tht for loop in c++ with the standard while loop in python... im not getting the arrays part... any help wud b appreciated
Python has string formatting much like C's:
-
floatStr = "%.3f" % 6.99999999
-
print floatStr, type(floatStr)
If you don't care about the formatting, just call the built-in str() method:
- aFloat = 4.9
-
print numberStr = str(aFloat)
-
print numberStr , type(numberStr )
for data storage in a text file, I often use a strings join() method:
- "\t".join(["%.3f" %aFloat, str(anInt)])
For true matrix work, you'll want to add SciPy to your installation.
Constructors for scipy arrays work much the same as in c.
It's really time for you to start using code tags in your posts. Instructions are on the right hand side of the page while posting.