Note also that there is nothing in your script that monitors a condition for it to break from the infinite while loop. Did you have one in mind? If not, it will never stop and just keep printing the results.
If you intend to run this loop for a fixed amount of iterations, then the for loop is a better option.
Edit: Never mind on this: It can return not False or True.
(I shouldn’t try analyzing code on my phone.)
Also, if you haven’t already, I would pick up a static code checker, like pylint. Such tools can pick up a whole host of issues without requiring you to run the code.
I still don’t understand what you expect the output to be. Given that you are randomizing the value of peso, output doesn’t seem like it should be deterministic. Here’s my latest version of your script. It runs and produces output, but as I indicated, I don’t know what to expect as far as output is concerned. Note also, that I might well have not got exactly what’s in your code, since you are posting screen shots, not text.
#!/usr/bin/env python3
"perceptron"
import random
peso = False
def aleatorizar():
"randomize"
global peso
peso = random.choice([False, True])
def activar(input1):
"activate"
return input1 if peso else not input1
def entrenar(input1, output1, intensity):
"train"
for _ in range(intensity):
if activar(input1) != output1:
aleatorizar()
for i in range(1000):
aleatorizar()
entrenar(False, True, 10)
entrenar(True, True, 10)
print(f"false => {activar(False)}, true => {activar(True)}")