Skip to content

(English) Variables

Luxs710 edited this page Mar 23, 2023 · 2 revisions

Variables

As it was explained in the home page, a variable can have 3 values at the same time, they are:

  • numeric value (float)

  • text value (string)

  • value of another variable (indicates the name of another variable in the code)

How to initialize a variable and change it's type:

is the brother

when using the command is the brother, the variable will be using it's numeric value, if the variable doesn't exist, it's created automatically, and it'll be using the numeric value.

Example:

Chico is the brother

is the sister

When using the command is the sister, the variable will be using it's text value, if the variable doesn't exist, it's created automaticcally and it'll be using the text value.

Example:

Chico is the sister

is good

When using the is good command, the program will print the name of the variable that's stored on the variable on the screen

Example:

Chico is good -> prints in the screen the name of the variable stored in Chico


Operations with variables

Assigning a value to a variable:

vale nada

When using the vale nada command, the numeric value of the variable is 0 (zero)

example:

Chico vale nada

vale tudo

When using the vale tudo command, the numeric value of the variable is 1

Example:

Chico vale tudo

vale <nmr>

When using the vale \<nmr\> command, the numeric value of the variable is the value of the <nmr>

example:

Chico vale 42

<x> vamos procurar viver em igualdade com <y>

When using the \<x\> vamos procurar viver em igualdade com \<y\> command, the numeric value of <x> it's the same as <y>

Example:

Chico is the brother
Chico vale 6

Birina is the brother
Birina, vamos procurar viver em igualdade com Chico

Other operations:

disse: <frase>

When using the disse: \<frase\> command, the text value of the variable is equals the <frase> that was passed, it can contain espaces and you can use \n to break lines

[espaço] can be used to represent a blank space

example:

Chico disse: Bom dia :)

pergunta: <frase>

When using the pergunta: \<frase\> command, the program will ask the user to inform a value, the value that will be informed by the user depends on the type of variable at the moment, the text in <frase> will be shown to the user.

example:

Chico is the sister changes the variable to it's text value Chico pergunta: Say your name: the text "Say your name:" will be shown to the user, the value that they will inform will be stored as the text value of the Chico variable

respondeu

When using the respondeu command, the program will print the value of the variable, the value printed depends on the type of the variable at the moment the respondeu command is called

example:

Chico is the sister -> Changes the variable to it's textual value

Chico disse: hi -> Assign "hi" as the text value

Chico respondeu -> print "hi" on the screen

Chico vale tudo -> Changes the numeric value to 1

Chico is the brother -> Changes the variable to it's numeric value

Chico respondeu -> print 1 on the screen

<x> e <y> é igual ao que, <z>?

When using the \<x\> e \<y\> é igual ao que, \<z\>? command, the program will sum the variables x and y and the result will be stored in z

example:

Chico is the brother
Birina is the brother

Chico vale 40
Birina vale 2

Melancia is the brother

Chico e Birina é igual ao que, Melancia?

at the end, Melancia has the numeric value of 42

<x> entre <y> e <z>, qual é a diferença?

When using the \<x\> entre \<y\> e \<z\>, qual é a diferença? command, the program will subtract the y and z variables and the result will be stored in x

example:

Chico is the brother
Birina is the brother
Melancia is the brother

Chico vale 44
Melancia vale 2

Melancia, entre Chico e Birina, qual é a diferença?

at the end Melancia has the numeric value 42


Comparing variables

<x> what is the brother <y> ou <z>?

When using the \<x\> what is the brother \<y\> ou \<z\>? command, the program will verify if y>y

if y>z:

  • X has the numeric value 1

  • X has the name of the variable Y

if y<z:

  • X has the numeric value 0

  • X has the name of the variable Z

example:

Birina is the brother
Chico is the brother
maior is the brother
Chico vale 25
Birina vale 5

maior what is the brother Chico ou Birina?
maior respondeu
maior is good

maior respondeu -> prints 1

maior is good -> Prints the name of the greatest variable (Chico)

<x> what is the sister <y> ou <z>?

When using the \<x\> what is the sister \<y\> ou \<z\>? command, the program will verify if y<z

if y<z:

  • X has the numeric value 1

  • X has the name of the variable Y

if y>z:

  • X has the numeric value 0

  • X has the name of the variable Z

exemplo:

Birina is the brother
Chico is the brother
maior is the brother
Chico vale 25
Birina vale 5

maior what is the sister Chico ou Birina?
maior respondeu
maior is good

maior respondeu -> prints 0

maior is good -> print the name of the lowest variable (Birina)

<x> fale o que quiser com <y>

When using this command, the text value is compared between x and y, if it's the same, the numeric value of x is 1, if it's false, the numeric value of x is 0