Skip to content
EspañolWorkspace →

Strings in PSeInt: solved text exercises

12 examples

How it works

A string is a sequence of characters: letters, digits, spaces and symbols. In PSeInt it's stored in a Caracter variable and written in quotes.

The string functions do the heavy lifting: Longitud counts characters, SubCadena takes a piece, Concatenar joins two texts, Mayusculas and Minusculas change the case, and ConvertirANumero and ConvertirATexto go from text to number and back.

To look at a text letter by letter, combine a Para with SubCadena(texto, i, i). That's how you count vowels, reverse a word or check for a palindrome.

Short example

The least you need to see it work. Copy it or open it in the editor.

strings.psc · 11 lines
Algoritmo ReverseWord    Definir palabra, invertida Como Caracter    Definir i Como Entero    Escribir "Type a word:"    Leer palabra    invertida <- ""    Para i <- Longitud(palabra) Hasta 1 Con Paso -1 Hacer        invertida <- invertida + SubCadena(palabra, i, i)    FinPara    Escribir "Reversed: ", invertidaFinAlgoritmo

What it prints:

Type a word:User answer: codeReversed: edoc
Open it in Codoritmo

Opens in the browser editor, nothing to install.

Solved exercises

Each exercise comes with the full code, its flowchart and a sample run.

  • Password Check

    Keeps asking for a password until it has at least 8 characters.

    Beginner
  • Name Initials

    Gets the initials of a full name.

    Beginner
  • Linear Search

    Finds a name in a list, ignoring upper and lower case.

    Intermediate
  • Palindromes

    Checks whether a phrase reads the same forwards and backwards.

    Intermediate
  • Count Vowels

    Counts the vowels, spaces and other characters in a text.

    Intermediate
  • Data Formatting

    Fixes upper and lower case, and converts between text and numbers.

    Intermediate
  • Reusable Validation

    Validates the email and age on a sign-up form.

    Intermediate
  • Caesar Cipher

    Encrypts a message by shifting each letter of the alphabet.

    Advanced
  • Roman Numerals

    Converts a number from 1 to 3999 into Roman numerals.

    Advanced
  • Base Conversion

    Writes a number in binary and hexadecimal.

    Advanced
  • Hangman

    Guess a secret word letter by letter, with six mistakes allowed.

    Advanced
  • Contact Book

    Add, list and search contacts in a book that grows.

    Advanced

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.