Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
programa = "while(true){if(a+b==0){print(a);}}"
def filter(instr):
tamanio = len(instr)
corchetes = ""
for x in range(0, tamanio):
if instr[x]=="{" or instr[x]=="}":
corchetes= corchetes + instr[x]
return corchetes
print filter(programa)
def delete(instr):
aux = filter(instr)
tamanio = len(aux)
borrado = ""
primero = False
encontro = False
colocar = True
borro = False
for x in range(0, tamanio):
if aux[x]=="{" and primero==False and borro==False:
primero=True
colocar=False
if aux[x]=="}" and primero==True and borro==False:
encontro=True
colocar=False
borro=True
if colocar:
borrado = borrado + aux[x]
colocar = True
if encontro:
return borrado
else:
return aux
print delete(programa)
print delete("{{}{}}")
print delete("}{{")
def recursiva_del(instr):
retorna=delete(instr)
if instr == delete(instr):
if instr == "":
return "El programa revisado tiene sintaxis correcta"
else:
return "El programa revisado tiene sintaxis incorrecta"
else:
return recursiva_del(retorna)
print recursiva_del(programa)
print "https://docs.google.com/a/mevsd.us/presentation/d/17_3jrltnZpuJ0Mqs5WPCOUB60wwsv1pSVF97glJgOq0/edit?usp=sharing"
#press execute
#copy and paste link
#sdpta
x1=[[1,1],[3,1],[-0.5,1],[-2.5,1]]
weight=[-2.5,1.75]
d=[1,1,-1,-1]
output=0
c=0.1
net=0
flag=True
training_cycle=0;
lambda1=1
while(flag):
flag=False
training_cycle=training_cycle+1
print "training cycle:",training_cycle
for i in range(len(x1)):
net=0
for j in range(len(weight)):
net=net+weight[j]*x1[i][j]
if net<0:
output=-1
elif net>0:
output=1
E=pow(d[i]-output,2)/2
if E!=0:
for k in range(len(weight)):
weight[k]=weight[k]+(c*(d[i]-output)*x1[i][k])/2
flag=True
print weight
print E