דילוג לתוכן
שאלה

Identifying an infinite loop

תצוגה מקדימה

מפתח התשובות מוצג למורים מחוברים.

Identifying an infinite loop

Which of the following loops never ends?

  1. while x < 10: print(x) (with x = 0 before the loop, and x is never changed inside the loop)

  2. while x < 10: x = x + 1 (with x = 0 before the loop)

  3. for i in range(-5): print(i)

  4. for i in range(10): x = x + 1


A while loop keeps running as long as its condition stays True. Ask yourself whether anything inside the loop could make the condition False.

פרטים

אין תיאור עדיין.

מקצועות
שפות תכנות
קהל יעד
תיכון · כיתות י׳–י״ב
רמת קושי
6 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
הושלם על ידי AI
מה שמסומן בניצוץ נוסף על ידי AI.
נוצר באמצעות AI
Claude Haiku 5.5
נוצר
עודכן
לפני 4 ימים

תגובות

  1. אין תגובות עדיין.
© כל הזכויות שמורות