Post

@PythonPr Correct → 21
while x < 20 means the body executes when x=18 → x=21, then exits.
Pro tip: if you want to stop exactly at or before 20, use ≤ or check inside the loop.
Drop your strangest while-loop bug below #PythonQuiz #LearnPython
English

@PythonPr B. 21 because when u loop until 18, it still less than 20
English

@PythonPr at 18 value becomes 21 condition failed
printed (x)
value :21
English

@PythonPr 1. When x = 18, satisfies the condition x < 20 augmented by 3 to increment it to 21
2. Print statement will output 21
English

@PythonPr التكرار السادس:
x = 15 + 3 → x = 18
هل 18 < 20؟ نعم، استمر.
· التكرار السابع:
x = 18 + 3 → x = 21
هل 21 < 20؟ لا، توقف عن الحلقة.
3. طباعة القيمة النهائية:
print(x) → 21
العربية

@PythonPr 21 cause when it’s 18 the loop will continue and add 3 and the next time it’ll not continue as x is 21
English

@PythonPr this loops adding 3 until it gets above 20 which is 21. 3+3+3+3+3+3+3=21. Math and code ugh
English

@PythonPr النتيجة:
سيتم طباعة الرقم 21، لأن آخر زيادة جعلت x = 21، وعندها يتحقق أن x لم تعد أقل من 20، فتتوقف الحلقة، ثم تطبع قيمة x النهائية.
العربية

@PythonPr التكرار الثالث:
x = 6 + 3 → x = 9
هل 9 < 20؟ نعم، استمر.
· التكرار الرابع:
x = 9 + 3 → x = 12
هل 12 < 20؟ نعم، استمر.
· التكرار الخامس:
x = 12 + 3 → x = 15
هل 15 < 20؟ نعم، استمر.
العربية

@PythonPr لنتتبع تنفيذ الكود خطوة بخطوة:
1. تهيئة المتغير:
x = 0
2. الحلقة while: الشرط x < 20
التكرار الأول:
x = 0 + 3 → x = 3
هل 3 < 20؟ نعم، استمر.
التكرار الثاني:
x = 3 + 3 → x = 6
هل 6 < 20؟ نعم، استمر.
العربية

@PythonPr 21. It starts at 0 and goes up by 3. At one iteration it's 18, but 18 < 20, so it iterates again, hits 21 and exits the loop.
English






















