[Tutor] writing files using modules and functions

2012-11-12 Thread Rufino Beniga
def MatInv(arr,file): f = open('file.txt','w') f.write(arr) f.close() So I'm trying to write a module that will take a matrix (arr) and write it to a text file. The above module is called MatrixIO.py #first I import it import MatrixIO #Then i call the function MatInv with matrix(a)

[Tutor] functions and iterations

2012-11-12 Thread Rufino Beniga
def IterateLogistic(x,r,n): for i in xrange(n): x = r*(1-x) if i = n: print x I want this function to take in x and r which can be any two real numbers and after a certain number of iterations (n), the function should print the current state which is x. I tried this

[Tutor] Retrieving numbers from a text

2012-10-23 Thread Rufino Beniga
*Problem*: Analyze a chaotic one-dimensional map: Write a program OneDMapAnalyze.py that reads the data in OneDMap.txt. Calculate the mean value of the iterates, printing the result to the terminal; again annotate the output so that it is understandable. Determine the fraction of iterates that have