Skip to content
EspañolWorkspace →

Logical operators Y, O, NO in PSeInt: examples

10 examples

How it works

Logical operators combine conditions. Y (and) is true only if both conditions are; O (or) if at least one is; NO (not) flips the result. They can also be written as &&, || and ~.

Y checks ranges: edad >= 13 Y edad <= 19. O accepts several answers: letra = "y" O letra = "Y". Use parentheses to make clear what is evaluated first.

A Logico variable holds true or false directly, like encontrado (found) or terminado (done). Mientras NO encontrado Hacer then reads almost like a sentence.

Short example

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

logical-operators.psc · 11 lines
Algoritmo CanEnter    Definir edad Como Entero    Definir conAdulto Como Logico    edad <- 15    conAdulto <- Verdadero    Si edad >= 18 O conAdulto Entonces        Escribir "Can come in"    SiNo        Escribir "Cannot come in"    FinSiFinAlgoritmo

What it prints:

Can come in
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.

  • Name Initials

    Gets the initials of a full name.

    Beginner
  • Guess the Number

    Guess a secret number from 1 to 100 in seven tries.

    Intermediate
  • Bubble Sort

    Sorts random numbers by swapping neighbors, and stops as soon as they're in order.

    Intermediate
  • Insertion Sort

    Inserts each number among the sorted ones, like arranging cards in your hand.

    Intermediate
  • Reusable Validation

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

    Intermediate
  • Shell Sort

    Insertion sort between far-apart elements, with a gap that shrinks every pass.

    Advanced
  • Heap Sort

    Arranges the array as a heap, then takes the largest out again and again.

    Advanced
  • Tic-Tac-Toe

    The classic three-in-a-row game for two players.

    Advanced
  • ATM

    Checks your PIN and lets you check, deposit and withdraw money.

    Advanced
  • Hangman

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

    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.