Paulo Andres Escobar Ingenieria de Sistemas, Orientacion a la Programacion el arte de crear Programas
Mostrando entradas con la etiqueta python. Mostrar todas las entradas
Mostrando entradas con la etiqueta python. Mostrar todas las entradas
viernes, 5 de octubre de 2012
convertir de octal a decimal
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string numero = textBox1.Text;
int y = numero.Length;
int Octal = int.Parse(numero);
double sumador = 0;
int x=y;
for (int i = 0; i < y; i++)
{
int ultimo_numero = Octal % 10;
Octal = Octal / 10;
if (ultimo_numero == 9)
{
i = y + 1;
MessageBox.Show("numero no es octal");
}
else
{
sumador = sumador + (Math.Pow(8, i) * ultimo_numero);
}
x = i;
}
if (x==y-1)
textBox2.Text = sumador.ToString();
else
textBox2.Text = "intenta de nuevo";
}
}
}
//por paulo andres escobar
jueves, 16 de agosto de 2012
Tablas de correlacion de estadistica en python
#tablas de correlacion
print("----------------TABLAS DE CORRELACIÓN-------------------------")
#obtenemos el tamaño del vector
tama = int(input("digite la cantidad de datos que va a ingresar"))
datos = [0]*tama #creamos el vector de la cantidad que tiene la variable tama
datos2 = [0]*tama
i= 0
SumatoriaX2=0
SumatoriaY2=0
SumatoriaY=0
SumatoriaX=0
sx2=0#sumatoria de x - xpromedio todo al cuadrado
sy2=0
sxy=0
#terminamos de definir algunas variables
############################################################
print ("ingrese datos de x para hallar correlacion")
while i < tama:
datos[i]=float (input ("dato: "))
SumatoriaX += datos[i] #sumamos todos los x
SumatoriaX2+=(datos[i]**2)
i+=1
print ("LOS DATOS INGRESADOS SON ",datos)
##########################################################
print ("ingrese datos de y ")
print ("ingrese sus datos")
Xpromedio= SumatoriaX/tama
i =0
while i < tama:
datos2[i]=float (input ("dato: "))
SumatoriaY+=datos2[i]
SumatoriaY2+=(datos[i]**2)
i+=1
Ypromedio= SumatoriaY/tama
i=0
print("-----------------------------------------------------------------------------------------------")
while i < tama:
print("--------intervalo ",i,"----------------------------------------------------------------")
print("|x| ",datos[i])
print("|y| ",datos2[i])
print("|X*Y| ",datos[i]*datos2[i])
print("|Xª2| ",datos[i]**2)
print("|Yª2| ",datos2[i]**2)
print("|x -X|",datos[i]-Xpromedio)
print("|y-Y|",datos2[i]-Ypromedio)
print("|x -X|ª2",(datos[i]-Xpromedio)**2)
print("|y-Y|ª2",(datos2[i]-Ypromedio)**2)
sx2+= (datos[i]-Xpromedio)**2
sy2+= (datos2[i]-Ypromedio)**2
sxy += datos[i]*datos2[i]
i+=1
print("-----------------------------------------------------------------------------------------------")
print("Fin Tabla")
print("-----------------------------------------------------------------------------------------------")
sx=(sx2/(tama-1))**(1/2)
print("sx=",sx)
#la raiz cuadrada de la sumatoria de x-xpromedio elevado al cuadrado dividido el numero de elementos
sy=(sy2/(tama-1))**(1/2)
b =((tama*sxy) - (SumatoriaX*SumatoriaY))/((tama*SumatoriaX2) - (SumatoriaX**2))
a = (SumatoriaY/tama)- (b*SumatoriaX/tama)
sxyy=(sxy/(tama))-(Xpromedio*Ypromedio)
print("sy=",sy)
print("sumatoria xy=",sxy)
print("promedio x",Xpromedio)
print("promedio y",Ypromedio)
r= sxyy/(sx*sy)
print ("la ecuacion de la linea recta es ")
print ("Y = ",a ," + ",b,"X")
print ("la correlacion es de",r,"sxy= ", sxyy)
if r>(-1) and r<=(-0.9):
print("!!!la correlacion es Excelente!!!!")
if r>=(0.8) and r<=(0.9):
print("!!!la correlacion es buena!!!")
if r>(0.6) and r<(0.8):
print("!!!la correlacion es regular!!!")
if r>(0.3) and r<(0.6):
print("!!!mala!!!")
martes, 3 de abril de 2012
juego de triqui en python
#triky
from turtle import*
speed(40)
pensize(4)
pu()
goto(-200,-200)
write('123\n456\n789',font=("arial",18,"bold"))
goto(-200,200)
pd()
fd(300)
rt(90)
fd(300)
rt(90)
fd(300)
rt(90)
fd(300)
rt(90)
fd(100)
rt(90)
fd(300)
pu()
lt(90)
fd(100)
lt(90)
pd()
fd(300)
pu()
goto(-200,100)
pd()
rt(90)
fd(300)
pu()
goto(-200,0)
pd()
fd(300)
pu()
contador=1
n1=0
n2=0
n3=0
n4=0
n5=0
n6=0
n7=0
n8=0
n9=0
sw=0
while contador <=9:
if contador<10:
n=numinput('','digite el numero donde quiere la x')
if n ==1:
goto(-160,130)
write('x',font = ("arial",30,"bold"))
n1=2
if n ==2:
goto(-60,130)
write('x',font = ("arial",30,"bold"))
n2=2
if n ==3:
goto(40,130)
write('x',font = ("arial",30,"bold"))
n3=2
if n ==4:
goto(-160,30)
write('x',font = ("arial",30,"bold"))
n4=2
if n ==5:
goto(-60,30)
write('x',font = ("arial",30,"bold"))
n5=2
if n ==6:
goto(40,30)
write('x',font = ("arial",30,"bold"))
n6=2
if n ==7:
goto(-160,-70)
write('x',font = ("arial",30,"bold"))
n7=2
if n ==8:
goto(-60,-70)
write('x',font = ("arial",30,"bold"))
n8=2
if n ==9:
goto(40,-70)
write('x',font = ("arial",30,"bold"))
n9=2
contador= contador +1
#####################################33
if n1==2 and n4==2 and n7==2 and sw ==0:
goto(-150,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
write('!!!TRIKI!!!!!',font=('arial',50,'bold'))
if n1==2 and n2==2 and n3==2 and sw ==0:
goto(-200,150)
pd()
fd(300)
contador=10
sw=1
if n1==2 and n5==2 and n9==2 and sw ==0:
goto(-200,200)
pd()
rt(45)
fd(430)
contador =10
sw=1
if n4==2 and n5==2 and n6==2 and sw ==0:
goto(-200,50)
pd()
fd(300)
contador=10
sw=1
if n7==2 and n8==2 and n9==2 and sw ==0:
goto(-200,-50)
pd()
fd(300)
contador=10
sw=1
if n2==2 and n5==2 and n8==2 and sw ==0:
goto(-50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==2 and n6==2 and n9==2 and sw ==0:
goto(50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==2 and n5==2 and n7==2 and sw ==0:
goto(100,200)
rt(135)
pd()
fd(430)
contador=10
sw=1
########################################################3
if contador <10 :
n=numinput('','digite el numero donde quiere la O')
if n ==1:
goto(-160,130)
write('O',font = ("arial",30,"bold"))
n1=1
if n ==2:
goto(-60,130)
write('O',font = ("arial",30,"bold"))
n2=1
if n ==3:
goto(40,130)
write('O',font = ("arial",30,"bold"))
n3=1
if n ==4:
goto(-160,30)
write('O',font = ("arial",30,"bold"))
n4=1
if n ==5:
goto(-60,30)
write('O',font = ("arial",30,"bold"))
n5=1
if n ==6:
goto(40,30)
write('O',font = ("arial",30,"bold"))
n6=1
if n ==7 :
goto(-160,-70)
write('O',font = ("arial",30,"bold"))
n7=1
if n ==8:
goto(-60,-70)
write('O',font = ("arial",30,"bold"))
n8=1
if n ==9:
goto(40,-70)
write('O',font = ("arial",30,"bold"))
n9=1
contador = contador +1
#########################################3
if n1==1 and n4==1 and n7==1 and sw ==0:
goto(-150,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n1==1 and n2==1 and n3==1 and sw ==0:
goto(-200,150)
pd()
fd(300)
contador=10
sw=1
if n1==1 and n5==1 and n9==1 and sw ==0:
goto(-200,200)
pd()
rt(45)
fd(430)
contador =10
sw=1
if n4==1 and n5==1 and n6==1 and sw ==0:
goto(-200,50)
pd()
fd(300)
sw=1
contador=10
if n7==1 and n8==1 and n9==1 and sw ==0:
goto(-200,-50)
pd()
fd(300)
contador=10
sw=1
if n2==1 and n5==1 and n8==1 and sw ==0:
goto(-50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==1 and n6==1 and n9==1 and sw ==0:
goto(50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==1 and n5==1 and n7==1 and sw ==0:
goto(100,200)
rt(135)
pd()
fd(430)
contador=10
sw=1
done()
from turtle import*
speed(40)
pensize(4)
pu()
goto(-200,-200)
write('123\n456\n789',font=("arial",18,"bold"))
goto(-200,200)
pd()
fd(300)
rt(90)
fd(300)
rt(90)
fd(300)
rt(90)
fd(300)
rt(90)
fd(100)
rt(90)
fd(300)
pu()
lt(90)
fd(100)
lt(90)
pd()
fd(300)
pu()
goto(-200,100)
pd()
rt(90)
fd(300)
pu()
goto(-200,0)
pd()
fd(300)
pu()
contador=1
n1=0
n2=0
n3=0
n4=0
n5=0
n6=0
n7=0
n8=0
n9=0
sw=0
while contador <=9:
if contador<10:
n=numinput('','digite el numero donde quiere la x')
if n ==1:
goto(-160,130)
write('x',font = ("arial",30,"bold"))
n1=2
if n ==2:
goto(-60,130)
write('x',font = ("arial",30,"bold"))
n2=2
if n ==3:
goto(40,130)
write('x',font = ("arial",30,"bold"))
n3=2
if n ==4:
goto(-160,30)
write('x',font = ("arial",30,"bold"))
n4=2
if n ==5:
goto(-60,30)
write('x',font = ("arial",30,"bold"))
n5=2
if n ==6:
goto(40,30)
write('x',font = ("arial",30,"bold"))
n6=2
if n ==7:
goto(-160,-70)
write('x',font = ("arial",30,"bold"))
n7=2
if n ==8:
goto(-60,-70)
write('x',font = ("arial",30,"bold"))
n8=2
if n ==9:
goto(40,-70)
write('x',font = ("arial",30,"bold"))
n9=2
contador= contador +1
#####################################33
if n1==2 and n4==2 and n7==2 and sw ==0:
goto(-150,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
write('!!!TRIKI!!!!!',font=('arial',50,'bold'))
if n1==2 and n2==2 and n3==2 and sw ==0:
goto(-200,150)
pd()
fd(300)
contador=10
sw=1
if n1==2 and n5==2 and n9==2 and sw ==0:
goto(-200,200)
pd()
rt(45)
fd(430)
contador =10
sw=1
if n4==2 and n5==2 and n6==2 and sw ==0:
goto(-200,50)
pd()
fd(300)
contador=10
sw=1
if n7==2 and n8==2 and n9==2 and sw ==0:
goto(-200,-50)
pd()
fd(300)
contador=10
sw=1
if n2==2 and n5==2 and n8==2 and sw ==0:
goto(-50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==2 and n6==2 and n9==2 and sw ==0:
goto(50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==2 and n5==2 and n7==2 and sw ==0:
goto(100,200)
rt(135)
pd()
fd(430)
contador=10
sw=1
########################################################3
if contador <10 :
n=numinput('','digite el numero donde quiere la O')
if n ==1:
goto(-160,130)
write('O',font = ("arial",30,"bold"))
n1=1
if n ==2:
goto(-60,130)
write('O',font = ("arial",30,"bold"))
n2=1
if n ==3:
goto(40,130)
write('O',font = ("arial",30,"bold"))
n3=1
if n ==4:
goto(-160,30)
write('O',font = ("arial",30,"bold"))
n4=1
if n ==5:
goto(-60,30)
write('O',font = ("arial",30,"bold"))
n5=1
if n ==6:
goto(40,30)
write('O',font = ("arial",30,"bold"))
n6=1
if n ==7 :
goto(-160,-70)
write('O',font = ("arial",30,"bold"))
n7=1
if n ==8:
goto(-60,-70)
write('O',font = ("arial",30,"bold"))
n8=1
if n ==9:
goto(40,-70)
write('O',font = ("arial",30,"bold"))
n9=1
contador = contador +1
#########################################3
if n1==1 and n4==1 and n7==1 and sw ==0:
goto(-150,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n1==1 and n2==1 and n3==1 and sw ==0:
goto(-200,150)
pd()
fd(300)
contador=10
sw=1
if n1==1 and n5==1 and n9==1 and sw ==0:
goto(-200,200)
pd()
rt(45)
fd(430)
contador =10
sw=1
if n4==1 and n5==1 and n6==1 and sw ==0:
goto(-200,50)
pd()
fd(300)
sw=1
contador=10
if n7==1 and n8==1 and n9==1 and sw ==0:
goto(-200,-50)
pd()
fd(300)
contador=10
sw=1
if n2==1 and n5==1 and n8==1 and sw ==0:
goto(-50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==1 and n6==1 and n9==1 and sw ==0:
goto(50,200)
rt(90)
pd()
fd(300)
contador=10
sw=1
if n3==1 and n5==1 and n7==1 and sw ==0:
goto(100,200)
rt(135)
pd()
fd(430)
contador=10
sw=1
done()
miércoles, 12 de octubre de 2011
comparar vectores en python
#llenar vectores
#comparar
#no permitir numeros repetidos
n = int(input('digite la cantidad de vectores a llenar'))
v=[0]*n
contador = 0
while contador < n:
num = int(input('digite el numero a guardar sin repetir'))
sw = 0
comparar = 0
while comparar <contador and sw==0:
if v[comparar] == num:
sw =1
print ('no se almaceno por que el numero esta repetido')
comparar = comparar +1
if sw==0:
v[contador]=num
contador = contador +1
print(v)
#comparar
#no permitir numeros repetidos
n = int(input('digite la cantidad de vectores a llenar'))
v=[0]*n
contador = 0
while contador < n:
num = int(input('digite el numero a guardar sin repetir'))
sw = 0
comparar = 0
while comparar <contador and sw==0:
if v[comparar] == num:
sw =1
print ('no se almaceno por que el numero esta repetido')
comparar = comparar +1
if sw==0:
v[contador]=num
contador = contador +1
print(v)
Suscribirse a:
Entradas (Atom)