ROUND, RANDOM and a trace · ROUND, RANDOM וטביעה
A shop rounds a price
ROUND(Value, Places)returnsValuerounded toPlacesdecimal places.Placesis an integer.ROUND(3.14159, 2)is3.14.ROUND(9.6, 0)is the whole number10.- The syllabus lists
ROUNDwithDIV,MODandRANDOM.
חנות מעגלת מחיר
ROUND(Value, Places)מחזירValueמעוגל ל-Placesמקומות עשרוניים.Placesהוא מספר שלם.ROUND(3.14159, 2)הוא3.14.ROUND(9.6, 0)הוא המספר השלם10.- הסילבוס מציין
ROUNDעםDIV,MODו-RANDOM.
OUTPUT ROUND(3.14159, 2)
OUTPUT ROUND(9.6, 0)
A dice uses RANDOM
RANDOM()returns a real from 0 to 1, including both ends. Each run can differ.- A board-game dice is
ROUND(RANDOM() * 6, 0). The paper uses it when the result may vary, so you are not asked for one fixed output.
קוביית משחק משתמשת ב-RANDOM
RANDOM()מחזיר מספר אמיתי מ-0 עד 1, כולל שני הקצוות. כל ריצה עשויה להיתרפות.- נדנדי משחק לוח היא
ROUND(RANDOM() * 6, 0). המסמך משתמש בה כאשר התוצאה עשויה להשתנות, ולכן אינו בוקש תוצאת יציאה אחת קבועה.
OUTPUT ROUND(RANDOM() * 6, 0)
Fill a trace table
- A trace table is a dry run. One row is one pass of the loop. You write the variables after that pass.
Totalstarts at 0. AfterI = 1it is 1. AfterI = 2it is 3. AfterI = 3it is 6.
| I | Total |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
מילוי טבלת מעקב
- טבלת מעקב היא הרצה יבשה. שורה אחת היא סיבוב אחד של לולאה. אתה כותב את המשתנים אחרי הסיבוב ההוא.
Totalמתחיל ב-0. לאחרI = 1הוא 1. לאחרI = 2הוא 3. לאחרI = 3הוא 6.
| I | סכום |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
One row per pass · שורה אחת לכל מעבר
A trace table records each variable after that pass of the loop. Here Total is the running sum of I. · טבלת טביעה מקליטה כל משתנה לאחר כל מעבר של הלולאה. כאן Total הוא הסכום הנאסף של I.
DECLARE I, Total : INTEGER
Total ← 0
FOR I ← 1 TO 3
Total ← Total + I
OUTPUT I, " ", Total
NEXT I
Watch out
- Round a half only when you have checked the digit. The tasks here are not on a halfway value.
RANDOM()is notRAND.RANDbelongs to the 9618 guide, not to this syllabus.
שימו לב
- עגל מחצית רק כאשר בדקת את הספרה. המשימות כאן אינן על ערך מחצית.
RANDOM()אינוRAND.RANDשייך למדריך 9618, ולא לתוכנית הלימודים הזו.
Common mistakes
ROUNDtakes the value first and the number of places second.- In a trace, record the values after the line has run, not the values you hope the next line will produce.
טעויות נפוצות
ROUNDלוקח תחילה את הערך ואז את מספר המקומות.- במעקב, הקלד את הערכים לאחר שהשורה נרצה, ולא את הערכים שמצפה שתפיק השורה הבאה.
Now you try
- The first task is
ROUND. The second prints a trace, one row per line. - Press Check answer to test it.
כעת תנסו בעצמכם
- המשימה הראשונה היא
ROUND. השנייה מדפסת עקבות, שורה אחת לכל שורה. - לחץ על בדיקת תשובה כדי לבדוק אותה.
Output ROUND(3.14159, 2) and ROUND(9.6, 0), each on its own line. · הדפס את ROUND(3.14159, 2) ואת ROUND(9.6, 0), כל אחד בשורה נפרדת.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Start Total at 0. For I from 1 to 3, add I to Total and output I, a space, and Total on that line. The three lines are the trace. · התחל עם Total בערך 0. עבור I מטווח 1 עד 3, הוסף I ל-Total והפלט I, רווח, ו-Total בשורה זו. השלוש שורות הן הטביעה.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.