Running total · סכום רץ
Running total
Add up the list [5, 10, 20] one number at a time, printing the total after each step: 5, 15, 35.
Lines indented under the for run every time round the loop; a line after the loop runs only once. Here the print belongs inside the loop.
סכום מצטבר
חשב את הסכום של הרשימה [5, 10, 20] מספר אחד באחד, והדפס את הסכום הכולל לאחר כל צעד: 5, 15, 35.
שורות מוזזות לתוך ה-for רצים בכל פעם שהלולאה מתחודשת; שורה אחרי הלולאה רצה רק פעם אחת. כאן ה-print נמצא בתוך הלולאה.
Loop over nums and keep a total. After adding each number, print the total so far: 5, then 15, then 35. · למעגל על nums ולשמור סכום מצטבר. לאחר הוספת כל מספר, הדפס את הסכום עד כה: 5, ולאחר מכן 15, ולאחר מכן 35.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.