March 23, 2025

Week 27 - Selection and loops practice

CLASS OBJECTIVE

Reinforce the use of the SI ENTONCES and the REPETIR commands by creating algorithms by yourself, just knowing the final result of the program.


INTRODUCTION

Last class you learned the use of SI ENTONCES to create multiple paths in an algorithm. By the analysis of  variables content the procedure can change and produce different outcomes.

Today you'll create by your self a program to analyze a word's length, obviously using SI ENTONCES, and after this you'll adapt the program to be repeated until the user chooses to exit.

Remember, you won't get any help from your teacher.



ACTIVITY 1

Remember, the activity's purpose is that you create the algorithm all by yourself so, you'll receive a just a couple of guidelines.

  1. Name the algorithm LONGITUD_DE_TEXTO
  2. Declare a variable to save a word
  3. Ask the user for a word and save it into the variable
  4. Tell the user IF the word's length has more than 15 characters (tip: you'll also have to use LONGITUD() function)
    • Otherwise, tell the user the word is smaller than 15 characters.
Look at the examples:




ACTIVITY 2

Now you have to add a loop to your first algorithm to repeat over and over until the user decides to finish it.

  1. Declare another variable to save a text
  2. You'll have to add the REPETIR/HASTA QUE command to wrap the last procedure.
  3. Inside the loop you'll have to ask the user if he wants to "try with another word", receive his answer and save it to the new variable.
  4. The algorithm will continue until the user types some letter different to the "s" letter.

Look at the examples:


If you need one last resource to finish your algorithm, look at the next flowchart:





CLASS NOTES

Write down in your notebook the title of the class, the objective and follow the instruction.

  1. What kind of data type you choose to save the user's incoming words? why?
  2. What does the LONGITUD() function do?
  3. Nested IF is a programing resource to add more answers to a SI-ENTONCES instruction,  Would it be possible to create a Nested IF in PSeInt? How?
  4. How did you indicate the "different to" comparison symbol?

Show your answers to your teacher.