Liftoff · שחרור לטיסה
Liftoff
Count down from 5 to 1, then print Liftoff!.
A while loop repeats as long as its condition is true, so something inside the loop must change the variable, or the loop never stops. Code written after the loop, without indentation, runs once when the loop ends.
שיגור
ספרו למטה מ-5 ועד 1, ואז הדפיסו Liftoff!.
לולאת while חוזרת כל עוד התנאי שלה אמת, ולכן משהו בתוך הלולאה חייב לשנות את המשתנה, או שהלולאה לעולם לא תיעצר. קוד שנכתב אחרי הלולאה, ללא הפרדה, יוצא לפועל פעם אחת כאשר הלולאה נגמרת.
Use a while loop to count down from 5 to 1, one number per line, then print Liftoff!. · השתמש במחזור while לספירה לאחור מ-5 ל-1, מספר אחד בכל שורה, ואז הדפס Liftoff!.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.