Skip to content · ⁨Passer au contenu⁩

Stop at the first over fifty · ⁨Arrêtez au premier dépassement de cinquante⁩

English

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.

Français

S'arrêter au premier supérieur à cinquante

n commence à 1. Continuez à ajouter 1 à elle. Dès que n * n est plus grand que 50, quittez la boucle avec break. Imprimez n après.

break quitte la boucle immédiatement. ⚠️ Il ne fonctionne qu'à l'intérieur de la boucle, donc la if qui la contient doit être indentée sous le while aussi — et la break indentée une fois de plus, sous le if. print(n) reste à gauche, hors de la boucle, donc elle s'exécute après le break.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP