Stop at the first over fifty · Parar no primeiro acima de cinquenta
Stop at the first over fifty
n starts at 1. Keep adding 1 to it. As soon as n * n is more than 50, leave the loop with break. Print n afterwards.
break leaves the loop at once. ⚠️ It only works inside the loop, so the if that holds it must be indented under the while too — and the break indented once more, under the if. print(n) stays at the left, outside the loop, so it runs after the break.
Parar no primeiro acima de cinquenta
n começa em 1. Continue somando 1 a ele. Assim que n * n for maior que 50, saia do loop com break. Imprima n depois.
break sai do loop imediatamente. ⚠️ Ele só funciona dentro do loop, então a if que o segura também deve estar indentada sob o while — e a break indentada mais uma vez, sob o if. print(n) fica na margem esquerda, fora do loop, então roda depois do break.
n starts at 1. Keep adding 1 to it. As soon as n * n is more than 50, leave the loop with break. Print n afterwards. · n começa em 1. Continue somando 1 a ele. Assim que n * n for maior que 50, saia do loop com break. Imprima n depois.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.