All pastes #411261 Raw Edit

MAS p1

public python v1 · immutable
#411261 ·published 2007-03-26 22:14 UTC
rendered paste body
#!/usr/bin/env pythonfrom math import *from modulepythong import *opcion = ''while opcion<'no' or opcion>'si':        print 'si quieres terminar teclea la palabra "no"'        opcion = raw_input('quieres continuar? ')        printif opcion=='no':        print 'el programa ha terminado'else:        #condiciones iniciales        x = float(raw_input('cual es la posicion inicial? '))        v = float(raw_input('cual es v? '))        k = float(raw_input('cual es k? '))        m = float(raw_input('cual es m? '))        dt = float(raw_input('cual es el paso de integracion? '))        #clear_output()        w = float(sqrt(k/m))        t = 2*pi/w        e = float(0.5*m*v**2+0.5*k*x**2)        n = float(sqrt(2*e/m))        b = float(sqrt(2*e/k))        print 'DATOS DEL OSCILADOR'        print 'Frecuencia','Periodo','Energia'        print        print '[ W=%4.3f     T=%4.3f     E=%4.3f]' % (w,t,e)        if b<n:                h = n+50                print 'La elipse es vertical'                window_coordinates(-h,-h,h,h)                create_line(0,-h,0,h,'blue') # Eje Y                create_line(-h,0,h,0,'blue') # Eje X                create_text(-h+10,0,'Espacio fase',10,'SW','red') # Etiqueta grafica                create_text(0,h-10,'V',10,'CENTER','red') # Etiqueta eje Y                create_text(h-10,0,'X',10,'CENTER','red') # Etiqueta eje X                j = 0                while j<1000:                        j += 1                        a = -(w**2)*x                        x_ant = x                        v_ant = v                        v = v+a*dt                        x = x+v*dt                        p = create_filled_circle(x,v,1.5,'black','cyan')                        erase(p)                        create_line(x_ant,v_ant,x,v,'red')        else:                i = b+50                print 'La elipse es horizontal'                window_coordinates(-i,-i,i,i)                create_line(0,-i,0,i,'blue') # Eje Y                create_line(-i,0,i,0,'blue') # Eje X                create_text(-i+10,0,'Espacio fase',10,'NW','red') # Etiqueta grafica                create_text(0,i-10,'V',10,'CENTER','red') # Etiqueta eje Y                create_text(i-10,0,'X',10,'CENTER','red') # Etiqueta eje X                j = 0                while j<1000:                        j += 1                        a = -(w**2)*x                        x_ant = x                        v_ant = v                        v = v+a*dt                        x = x+v*dt                        p = create_filled_circle(x,v,1.5,'black','cyan')                        erase(p)                        create_line(x_ant,v_ant,x,v,'red')raw_input('')