Stop at the first over fifty · توقف عند أول عدد يتجاوز الخمسين
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.
توقف عند أول تجاوز الخمسين
يبدأ n عند 1. استمر في إضافة 1 إليه. بمجرد أن يصبح n * n أكبر من 50، غادر الحلقة مع break. اطبع n بعد ذلك.
يغادر break الحلقة فوراً. ⚠️ يعمل فقط داخل الحلقة، لذا يجب أن يكون if الذي يحمله مزاحاً تحت while أيضاً — ومرة أخرى break مزاحاً تحت if. يبقى print(n) على الهامش، خارج الحلقة، لذا يعمل بعد أمر الإيقاف.
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 عند 1. استمر في إضافة 1 إليه. بمجرد أن يصبح n * n أكبر من 50، غادر الحلقة مع break. اطبع n بعد ذلك.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.