import evaluar 
from pylab import * 
from numpy import *

def puntofijo(po,TOL, N): 
 vectorx = zeros (N, Float64)
 vectory = zeros (N, Float64)

i = 1 
while i<=N :
 vectorx[i-1] = po 
Evaluar.dicc_seguro['x']=po 
fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) 
vectory[i-1]=fp                                                                      
if fabs(po-fp):
 print "La raiz buscada es: ",po, "con", i-1, "iteraciones" 
 sys.exit()
i = i+1 
po = fp 
quit() [vectorx,vectory]

def dibujar(po,TOL, ): 
 x = arange(po-2,po+2,0.1) 
vectores=puntofijo(po, TOL, Y)

subplot(211) 
plot(x, eval(Evaluar.funcion), linewidth=1.0) 
xlabel('Abcisa') 
ylabel('Ordenada') 
title('Metodo Punto Fijo con f(x)= x - ' + Evaluar.funcion) 
grid(True) 
axhline(linewidth=1, color='r') 
axvline(linewidth=1, color='r')

subplot(212) 
plot(vectores[0], vectores[1], 'k.') 
xlabel('Abcisa') 
ylabel('Ordenada') 
grid(True) 
axhline(linewidth=1, color='r') 
axvline(linewidth=1, color='r')
show() 
def puntofijo(po,TOL, N): 
 vectorx = zeros (N, Float64)
 vectory = zeros (N, Float64)

i = 1 
while i<=N :
 vectorx[i-1] = po 
Evaluar.dicc_seguro['x']=po 
fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) 
vectory[i-1]=fp                                                                      
if fabs(po-fp):
 print "La raiz buscada es: ",po, "con", i-1, "iteraciones" 
 sys.exit()
i = i+1 
po = fp 
quit() [vectorx,vectory]

I assume that this is all supposed to be a single function, correct? If so, then the indentation is off, starting at line 9 (the i = 1 line). Try:

import evaluar 
from pylab import * 
from numpy import *

def puntofijo(po,TOL, N): 
    vectorx = zeros (N, Float64)
    vectory = zeros (N, Float64)

    i = 1 
    while i<=N :
        vectorx[i-1] = po 
    Evaluar.dicc_seguro['x']=po 
    fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro)
    vectory[i-1]=fp     
    if fabs(po-fp):
        print "La raiz buscada es: ",po, "con", i-1, "iteraciones" 
        sys.exit()
    i = i+1 
    po = fp 
    quit() [vectorx,vectory]

def dibujar(po,TOL, ): 
    x = arange(po-2,po+2,0.1) 
    vectores=puntofijo(po, TOL, Y)

    subplot(211) 
    plot(x, eval(Evaluar.funcion), linewidth=1.0) 
    xlabel('Abcisa') 
    ylabel('Ordenada')
    title('Metodo Punto Fijo con f(x)= x - ' + Evaluar.funcion) 
    grid(True) 
    axhline(linewidth=1, color='r') 
    axvline(linewidth=1, color='r')
    subplot(212) 
    plot(vectores[0], vectores[1], 'k.') 
    xlabel('Abcisa')
    ylabel('Ordenada') 
    grid(True) 
    axhline(linewidth=1, color='r') 
    axvline(linewidth=1, color='r')
    show() 

Note that the convention in Python is to use four spaces for indentation, not two. Also, what is the line quit() [vectorx,vectory] meant to do? I am pretty sure that the list following the quit() call is likely to give you a syntax error. For that matter, where is the function quit() coming from? If you are intending to return the pair [vectorx, vectory] as the function return value, you would use return vectorx, vectory instead.

I copy your code but throw this error

File "C:\Users\manuela\Desktop\Metodos\PuntoFijo.py", line 20
    break 
    ^
IndentationError: unexpected indent

thanks

Interesting. There are no break statements in the code you posted, which leads me to think that this is from theevaluar module which you are importing, or else some other file that it in turn imports.

Stupid Python indentation rules! One of the many reasons I despise the language! Personally, I think the authors of the language took their Monty Python analogies way too far! Not to mention that they were too lazy to input a couple of squiggly braces to scope stuff. Who knows. Maybe their keyboard(s) were broken and the squiggly braces didn't work!

Ok. Done ranting now... :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.