PSeInt profile ET28
These are the rules of the ET28 profile, explained simply, with an example that follows them and opens in Codoritmo with one click.
Opens this page's example with the ET28 profile already switched on.
How its author describes it
The profile's original text, in Spanish, as distributed with PSeInt.
- Materia
- Taller de Tecnologías de la Información y la Comunicación (TICs)
- Carrera
- Técnico Electrónico
- Institución
- Escuela Técnica Nro 28, Distrito Escolar Nro 10, República francesa
- Ubicación
- Ciudad de Buenos Aires, Argentina
- Perfil enviado por
- A.D. Santo Domingo
In short
What changes compared with Codoritmo's default profile:
- No accents or ñ in variable names
- No conditions like Es Par: comparisons use operators
- Arrays start at 0
- Repetir only ends with Hasta Que
- Counting down needs Con Paso -1
- Segun only works with whole numbers
All of its rules
Marked rules differ from Codoritmo's default profile; everything else behaves the same.
Variables
How they are declared and when they can be used.
- Declare variables with Definir
- Optional. You can use a variable without declaring it: its type comes from the first value you store in it.
- Give a value before use
- Not checked. It's still good practice to give every variable a value before using it.
- Protected Para counter
- You can change the counter inside the
Paraand keep using it after the loop ends. - Accents and ñ in namesDiffers from default
- Not allowed in variable or subroutine names: write
anioorposicion. Accented keywords such asSegúnstill work.
Writing style
Punctuation, closing words and how values are assigned.
- Semicolon at the end
- Optional. You can end statements with
;or leave it out. - Relaxed syntax
- Accepts handy variants:
Fin Sias two words, optionalEntoncesandHacer,Mientras QueandDesdein loops, and values inEscribirseparated by spaces. - Assign with =
- Not allowed: you assign only with
<-;=is only for comparing.
Operators and conditions
How comparisons are written and text is put together.
- Word operators
- You can write
Y,O,NOandMOD(and, or, not, remainder) as well as their symbols&,|,~and%. - Plain-language conditionsDiffers from default
- Doesn't accept them: write the comparison with operators, such as
x MOD 2 = 0orx > 5. - Join text with +
- Allowed:
"Hola, " + nombremakes a single piece of text.
Arrays
Where indexes start and how the size is set.
- First array indexDiffers from default
- Arrays start at 0: after
Dimension notas[3]the slots arenotas[0],notas[1]andnotas[2]. - Array size from a variable
- Allowed: you can read
nand then writeDimension datos[n]. - Resize arrays
- You can change the size of an existing array with
Redimensionar.
Loops and Segun
Which ways of repeating and choosing between cases it accepts.
- Para Cada loop
- Available:
Para Cada nota de notas Hacergoes through every slot of an array. - Repetir … Mientras QueDiffers from default
- A
Repetirloop can only end withHasta Que condition(until). - Para counting downDiffers from default
- To count down you must write
Con Paso -1; without it,Para i <- 3 Hasta 1doesn't run at all. - Segun with whole numbersDiffers from default
- The value a
Segunchecks, and its options, must be whole numbers.
Subroutines and text functions
Which extra tools you get to organise the program.
- Your own subroutines and functions
- You can write your own
SubProcesoorFuncionto split the program into parts. - Text functions
- Available:
Longitud,Subcadena,Mayusculas,MinusculasandConcatenar(length, substring, upper case, lower case, join).
An example that follows these rules
It works out the average of three marks. It's written for this profile, and the comments point out what changes compared with the default. We checked it with Codoritmo's interpreter using these same rules.
// Example written with the rules of the ET28 profileAlgoritmo PerfilET28 // Variable names have no accents or ñ Dimension notas[3] // Arrays start at 0: the slots are 0, 1 and 2 notas[0] <- 8 notas[1] <- 9 notas[2] <- 7 suma <- 0 Para i <- 0 Hasta 2 Hacer suma <- suma + notas[i] FinPara promedio <- suma / 3 nombre <- "Ana" Escribir "Hi, ", nombre Escribir "Average: ", promedio Si promedio >= 7 Y promedio <= 10 Entonces Escribir "Passed" SiNo Escribir "Failed" FinSi // Es Par isn't accepted: the condition uses operators Si suma MOD 2 = 0 Entonces Escribir "The sum is even: ", suma SiNo Escribir "The sum is odd: ", suma FinSi // Segun only accepts whole numbers Segun notas[0] Hacer 10: Escribir "The first mark is excellent" 8, 9: Escribir "The first mark is very good" De Otro Modo: Escribir "The first mark can improve" FinSegun Escribir "Countdown:" // Counting down needs Con Paso -1 Para i <- 3 Hasta 1 Con Paso -1 Hacer Escribir i FinPara // Repetir can only end with Hasta QueFinAlgoritmoWhat it prints
This is the example's real output, run with the ET28 profile.
Hi, Ana Average: 8 Passed The sum is even: 24 The first mark is very good Countdown: 3 2 1
Examples that touch these rules
They open with the default profile; switch to yours from the editor's bottom bar.
Grade Average
Stores five grades in an array and finds the average and the highest.
BeginnerFactorial and Power
Functions that compute a factorial and a power.
IntermediateCount Vowels
Counts the vowels, spaces and other characters in a text.
Intermediate