Variables, DECLARE and CONSTANT
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · עמוד זה דורש דפדפן עדכני (תומך ב-SharedArrayBuffer). אנא עדכן את Chrome, Edge, Firefox או Safari לגרסה העדכנית ביותר.
English
A variable stores a value
- A variable holds a value you can use and change.
- The arrow
←puts a value into a variable (this is assignment). - On your keyboard, type
<-(less-than, minus) — it means the same as←.
עברית
משתנה מאחסן ערך
- משתנה אחוסן ערך שניתן להשתמש בו ולשנות אותו.
- החץ
←מכניס ערך לתוך משתנה (זהו הקצה). - במקלדת, כתוב
<-(סימן פחות, מקש מינוס) — זה אומר אותו דבר כמו←.
Age ← 16
OUTPUT Age // → 16
OUTPUT "Age" // → Age
English
DECLARE names the type
DECLAREstates a variable's name and its data type.- It is good style to declare a variable before you use it.
עברית
DECLARE מגדיר את הסוג
DECLAREמציין שם של משתנה ואת סוג הנתונים שלו.- נהוג להגדיר משתנה לפני השימוש בו.
DECLARE Count : INTEGER
Count ← 0
OUTPUT Count // → 0
English
You can change a variable
- Assign again to give a variable a new value.
- The right-hand side is worked out first, then stored.
עברית
ניתן לשנות משתנה
- מוסיפים מחדש כדי לתת למשתנה ערך חדש.
- הצד הימני מחושב ראשית, ולאחר מכן מאוחסן.
Total ← 10
Total ← Total + 5
OUTPUT Total // → 15
Explore · חקור
Watch the value change
← puts a value into a box. Assign again, and the box holds the new value.
English
A constant does not change
- A constant is a name for a value the program must not change, such as a pass mark or an hourly rate.
- The 2026–2028 syllabus writes
CONSTANT HourlyRate ← 6.50— the arrow, then a literal only. - If the number changes next year, you edit that one line and every use of the name follows.
עברית
קבוע אינו משתנה
- קבוע הוא שם לערך שאינו חייב להשתנות בתוכנית, כגון ציון מעבר או תעריף שעתי.
- המסלול ל-2026–2028 כותב
CONSTANT HourlyRate ← 6.50— החץ, ולאחר מכן ערך ליטראלי בלבד. - אם המספר משתנה בשנה הבאה, תערוך רק את השורה הזו וכל שימוש בשם ייעודכן.
CONSTANT PassMark ← 50
OUTPUT PassMark // → 50
English
Watch out
←(or<-) means store into. It is not the=used to test equality.- A variable keeps its last value until you assign a new one.
OUTPUT Ageprints the number in the box.OUTPUT "Age"prints the word Age.
עברית
שימו לב
←(או<-) פירושו אחסן בתוך. זו אינה ה-=המשמשת לבדיקת שוויון.- משתנה שומר על הערך האחרון שלו עד שתמסור לו ערך חדש.
OUTPUT Ageמדפיס את המספר בתוך הקופסה.OUTPUT "Age"מדפיס את המילה Age.
English
Common mistakes
DECLARE <identifier> : <data type>before you use a variable.- A constant is
CONSTANT <identifier> ← <value>. Assign a variable with←.
עברית
טעויות נפוצות
DECLARE <identifier> : <data type>לפני השימוש במשתנה.- קבוע הוא
CONSTANT <identifier> ← <value>. מסדרים משתנה בעזרת←.
English
Now you try
- Type
<-for the←arrow. - Press Run to see the output, then Check answer.
עברית
כעת תנסו בעצמכם
- כתוב
<-עבור ה-←החץ. - לחץ על Run כדי לראות את התוצאה, ולאחר מכן לחץ על Check answer.
Put 16 into a variable called Age, then OUTPUT it. (Type <- for the ← arrow.)
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
DECLARE a variable Price as INTEGER, set it to 3, then OUTPUT Price * 4 (the answer is 12).
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Set Total to 10, then add 5 to it, then OUTPUT Total (the answer is 15).
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Declare a constant PassMark with the value 50, using ←, then OUTPUT it.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.