Variables, DECLARE and CONSTANT · Variáveis, DECLARE e CONSTANT
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←.
Uma variável armazena um valor
- Uma variável guarda um valor que você pode usar e alterar.
- A seta
←coloca um valor em uma variável (isso é atribuição). - No seu teclado, digite
<-(menos, hífen) — significa o mesmo que←.
Age ← 16
OUTPUT Age // → 16
OUTPUT "Age" // → Age
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 nomeia o tipo
DECLAREdeclara o nome de uma variável e seu tipo de dado.- É boa prática declarar uma variável antes de usá-la.
DECLARE Count : INTEGER
Count ← 0
OUTPUT Count // → 0
You can change a variable
- Assign again to give a variable a new value.
- The right-hand side is worked out first, then stored.
Você pode alterar uma variável
- Atribua novamente para dar à variável um novo valor.
- O lado direito é calculado primeiro, depois armazenado.
Total ← 10
Total ← Total + 5
OUTPUT Total // → 15
Watch the value change · Observe o valor mudar
← puts a value into a box. Assign again, and the box holds the new value. · ← coloca um valor em uma caixa. Atribua novamente, e a caixa conterá o novo valor.
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.
Uma constante não muda
- Uma constante é um nome para um valor que o programa não deve alterar, como uma nota mínima ou taxa horária.
- O programa 2026–2028 escreve
CONSTANT HourlyRate ← 6.50— a seta, seguida apenas por um literal. - Se o número mudar no ano seguinte, você edita essa única linha e todo uso do nome segue.
CONSTANT PassMark ← 50
OUTPUT PassMark // → 50
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.
Atenção
←(ou<-) significa armazenar em. Não é o=usado para testar igualdade.- Uma variável mantém seu último valor até que você atribua um novo.
OUTPUT Ageimprime o número na caixa.OUTPUT "Age"imprime a palavra Age.
Common mistakes
DECLARE <identifier> : <data type>before you use a variable.- A constant is
CONSTANT <identifier> ← <value>. Assign a variable with←.
Erros comuns
DECLARE <identifier> : <data type>antes de usar uma variável.- Uma constante é
CONSTANT <identifier> ← <value>. Atribua uma variável com←.
Now you try
- Type
<-for the←arrow. - Press Run to see the output, then Check answer.
Agora você tenta
- Digite
<-para a seta do←. - Pressione Run para ver a saída, depois Check answer.
Put 16 into a variable called Age, then OUTPUT it. (Type <- for the ← arrow.) · Coloque 16 em uma variável chamada Age, depois OUTPUT ela. (Digite <- para a ← seta.)
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
DECLARE a variable Price as INTEGER, set it to 3, then OUTPUT Price * 4 (the answer is 12). · DECLARE uma variável Price como INTEGER, defina-a como 3, depois OUTPUT Price * 4 (a resposta é 12).
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Set · Definir Total to · até 10, then add 5 to it, then OUTPUT Total (the answer is 15). · Defina Total como 10, depois some 5 a ela, depois OUTPUT Total (a resposta é 15).
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Declare a constant PassMark with the value 50, using ←, then OUTPUT it. · Declare uma constante PassMark com o valor 50, usando ←, depois OUTPUT ela.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.