"""Programa Creado Por Marcos Ochoa Diez Para Symbian Para Calcular Los Decimales De Pi Que Queramos En Python Tanto En Pantalla Como En Fichero""" import math, time import appuifw import e32 def _raw_input( txt ): return appuifw.query( unicode( txt ), "text" ) def tiempo(n): HOR=n/3600 MIN=(n /60)%60 SEG= n % 60 return (str(HOR)+"h:"+str(MIN)+"m:"+str(SEG))+"s" appuifw.app.title=u"^MvIiIaX^ Decim-PI" appuifw.note(u"Bienvenid@ Al Programa Calculador De Decimales De Pi Por ^MvIiIaX^.", "info" ) cuantos= int( _raw_input("M8AX Dime Cuantos Decimales De Pi Quieres Sacar: ") ) porpantalla= int( _raw_input("M8AX Donde Quieres El Resultado 1-Pantalla 2-Fichero: ") ) if porpantalla==2: f = open( "e:\\M8AX-S60-DecPi.TxT", "w" ) def arccot(x, unity): sum = xpower = unity // x n = 3 sign = -1 while 1: e32.ao_yield() xpower = xpower // (x*x) term = xpower // n if not term: break sum += sign * term sign = -sign n += 2 return sum def pi(digits): unity = 10**(digits + 10) pi = 4 * (4*arccot(5, unity) - arccot(239, unity)) return pi appuifw.app.screen = 'full' resta=0 start_t = time.time() if porpantalla==1: print pi(cuantos) if porpantalla==2: f.write("M8AX - RESULTADO DEL CALCULO DE DECIMALES DE PI\n ") if porpantalla==2: f.write( "-----------------------------------------------------------\n" ) f.write("%d" %pi(cuantos)) f.write( "\n-----------------------------------------------------------" ) resta=time.time()-start_t if resta < 1: resta=1 print resta, " ... Segundos Procesando Decimales ...\n" print tiempo(int(resta)), "... Tiempo De Proceso De Decimales De Pi ...\n" print "%d Decimales De Pi Por Segundo Calculados..." % int(cuantos/resta) if porpantalla==2: f.write( "\nSEGUNDOS EMPLEADOS EN EL CALCULO DE DECIMALES DE PI - " ) f.write ("%d\n" % int(resta)) f.write( "TIEMPO CONSUMIDO EN EL CALCULO DE DECIMALES DE PI - " ) f.write (tiempo(int(resta))) f.write( "\nDECIMALES DE PI CALCULADOS %d HA UN RITMO DE %d DECIMALES POR SEGUNDO" % (cuantos, int(cuantos/resta) )) f.write("\nFIN DEL CALCULO DE DECIMALES DE PI") f.write("\n^MvIiIaX^ Corp. 2006\n") f.write( "-----------------------------------------------------------" ) print "\n^MvIiIaX^ Corp. 2006" appuifw.note(u"... El Cálculo Ha Sido Realizado ...", "info" ) if porpantalla==2: f.close()