Variables in PSeInt: examples to get started
3 examples
How it works
A variable is a named place where the program keeps a value to use later: an age, a price, a name. You can change its value as often as you like; the variable always remembers the latest one.
Definir says what kind of data it will hold: Entero for whole numbers, Real for numbers with decimals, Caracter for text and Logico for true or false. Depending on your school's profile, Definir may be required.
To store a value you use the <- arrow, read as "gets". The right-hand side is worked out first, so total <- total + precio means "add the price to total".
Short example
The least you need to see it work. Copy it or open it in the editor.
Algoritmo Variables Definir precio, total Como Real Definir cantidad Como Entero precio <- 2.5 cantidad <- 4 total <- precio * cantidad Escribir "Total to pay: ", totalFinAlgoritmoWhat it prints:
Total to pay: 10Opens in the browser editor, nothing to install.
Solved exercises
Each exercise comes with the full code, its flowchart and a sample run.
Personal Greeting
Asks for your name and age, and answers with both.
BeginnerTemperature Converter
Converts degrees Celsius to Fahrenheit and Kelvin.
BeginnerTip Calculator
Splits a restaurant bill, tip included.
Beginner
In the language reference
The instructions involved, explained one by one.
Other concepts
Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.