// The rule for how this API handles Python 'print' output:
// If we have an element with id="ab-python-console" then 'print' appends to it.
// If such an element does not exist, 'print' writes to the console.
// choose one of:
// <script type="py">
// <script type="mpy">
document.write ( `
<div id="ab-python-console" style='padding:30' ></div>
<script type="mpy">
print ("<h1> Python on Ancient Brain </h1>")
print ("<p style='color:green'><b> Python demo generating prime numbers and printing them </b></p>")
# --- generate prime numbers: -----------------------------------------------------
primes = [2]
num = 3
while len(primes) < 100:
if all(num % p != 0 for p in primes):
primes.append(num)
print(num)
num += 2
# print(*primes) # print them all, separated by spaces
# ----------------------------------------------------------------------------
</script>
` );