User Profile

Collapse

Profile Sidebar

Collapse
Gordon Haag
Gordon Haag
Last Activity: Jan 24 '11, 02:13 AM
Joined: Dec 31 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • I figured it out.

    This loop prints the way I need to:
    Code:
        while abs(b**2-a)>e and steps<10000.:
            steps=steps+1
            b=(b+a/b)/2
            currenttotal=currenttotal+b
            written=currenttotal
            print>>squarerootfile, written
            print steps
    This prints with \n after each entry:
    Code:
        while abs(b**2-a)>e and steps<10000.:
    ...
    See more | Go to post
    Last edited by bvdet; Jan 1 '11, 01:51 PM. Reason: Add code tags

    Leave a comment:


  • I tried to do what you said, but the way you use i confuses me. Does 'for i, line in...' tell python that i is a line in ...? What does line.strip do?

    Here is pseudo-code of what I am trying to do.

    Code:
    path='c:\\pythonfiles2\\totalsqrtdone.txt'
    fun=file(path, "r")
    line=1
    while line<100000000:
        a=readline.fun(line)
        plotdot(line,a)
        line=line+1
    The...
    See more | Go to post

    Leave a comment:


  • Gordon Haag
    started a topic How to convert string with letters to float?

    How to convert string with letters to float?

    I am trying to do a little bit of numeric computing. I wrote a program that writes the result of each iteration of a function to a file. I want to graph these results as dots using vpython, but I am unable to do so.

    I need each value to be on its own line in the text file, so I am using this to write the value to the text file:
    Code:
    written=str(currenttotal)
    squarerootfile.write(written)
    squarerootfile.write("\n")
    ...
    See more | Go to post
No activity results to display
Show More
Working...