Conceptos de Lógica de la Programación N: 1

Fuente/Source


cintillo_hive.png


Antes que nada cordiales saludos a la comunidad de #Linux&SoftwareLibre y para toda la comunidad de #Linux en #Hive, como lo comentamos el viernes pasado, en el post del #ViernesDeEscritorio, esperamos iniciar el próximo viernes el curso del software PseInt.
Pero para poder avanzar y poder profundizar en el manejo del programa, los usuarios debemos conocer ciertos términos y conceptos, y en vez de hacer un glosario que fue lo que pensé hacer en el principio, me decidí a hacer post y explicar de manera sencilla y con ejemplos, los conceptos más usados, para poder avanzar con una buena base teórica en el curso.

Para iniciar, vamos a explicar dos conceptos que van a ser muy utilizados, no solamente en el curso, sino en el área de la programación, que son los conceptos de algoritmo y de variable.


¿Qué es un algoritmo?


Cuando hablamos de un algoritmo en el proceso de la programación, nos referimos a una secuencia de pasos bien definidos y ordenado, utilizados para resolver un problema específico.
Es decir, el algoritmo, teóricamente, es la base de la programación, ya que permite a los programadores crear soluciones a través de instrucciones claras y lógicas.


Los algoritmos son importantes por las siguientes razones:


  • Permiten estandarizar la resolución de problemas de manera eficiente.
  • Facilitan la comprensión y el mantenimiento del código.
  • Ayudan a identificar y corregir errores de forma más sencilla.
  • Pueden ser reutilizados en diferentes programas o situaciones.

Ahora utilizaremos como ejemplo un algoritmo sencillo para que se conozca su funcionamiento:

Haremos un algoritmo para calcular el área de un rectángulo:


Inicio:

Solicitar al usuario que ingrese la base del rectángulo
Solicitar al usuario que ingrese la altura del rectángulo
Calcular el área multiplicando, la base por la altura
Mostrar el resultado del área

Fin


Hagamos un Paso a paso:


  1. Inicio: Marca el comienzo del algoritmo.

  2. Solicitar al usuario que ingrese la base del rectángulo: Se le pide al usuario que proporcione el valor de la base del rectángulo.

  3. Solicitar al usuario que ingrese la altura del rectángulo: Se le pide al usuario que proporcione el valor de la altura del rectángulo.

  4. Calcular el área multiplicando la base por la altura: Se toman los valores proporcionados por el usuario y se multiplican para obtener el área del rectángulo.

  5. Mostrar el resultado del área: Se presenta al usuario el resultado del cálculo del área.

  6. Fin: Marca el final del algoritmo.


Este es un ejemplo bastante sencillo de lo que es un algoritmo, en él se ve la base de la lógica de la programación, ya que a través de la solución de los algoritmos, le enseñamos a una computadora a actuar para resolver un problema específico, en este caso, es el calcular el área de un rectángulo.

Como se puede ver, los pasos del algoritmo, están claramente definidos, y así se pueden pasar fácilmente a un lenguaje de programación, para enseñarle a una computadora como calcular el área de un triángulo, a través de un paso a paso.


Fuente/Source


¿Qué es una variable?


Una variable, en el ámbito de la programación, es un espacio en la memoria del computador que se utiliza para almacenar y manipular datos. Algunos de los tipos de variables más comunes son:

  • Enteros (int) - para números enteros
  • Flotantes (float) - para números con decimales
  • Cadenas de texto (string) - para almacenar texto
  • Booleanos (bool) - para valores de verdadero o falso

Las variables son importantes porque:


  • Permiten almacenar y procesar información de manera dinámica.
  • Facilitan la organización y el manejo de datos en el programa.
  • Hacen más flexible y adaptable la lógica del programa.
  • Permiten reutilizar y modificar fácilmente los valores durante la ejecución.

Ejemplo de variables:


Supongamos, que nosotros queremos crear un programa que calcule el área de un círculo, y para poder hacer eso, necesitaremos almacenar el valor del radio del círculo en una variable.

En nuestro caso lo haremos a nivel práctico, utilizando un pseudocódigo, en el programa PesInt, pero para este ejemplo, sería algo así:


Inicio

Declarar una variable 'radio' de tipo numérico
Solicitar al usuario que ingrese el valor del radio

Calcular el área del círculo utilizando la fórmula: área = π * radio^2
Mostrar el resultado del área

Fin


Analicemos este ejemplo paso a paso:


  1. Declarar una variable 'radio' de tipo numérico: Aquí estamos creando una variable llamada 'radio' que va a almacenar un valor numérico, que será el radio del círculo.

  2. Solicitamos al usuario que ingrese el valor del radio: Le pedimos al usuario que ingrese el valor del radio del círculo que quiere calcular, sea cual sea este.

  3. Calcular el área del círculo utilizando la fórmula: área = π * radio^2: Aquí usamos la variable 'radio' que contiene el valor proporcionado por el usuario para calcular el área del círculo aplicando la fórmula correspondiente.

  4. Mostrar el resultado del área: Finalmente, mostramos al usuario el resultado del cálculo del área del círculo.

En este ejemplo, la variable 'radio' es fundamental para poder realizar el cálculo del área, sin ella, no podríamos obtener el valor que necesitamos para aplicar la fórmula.

Entonces, debemos recordar, que las variables nos permiten almacenar y manipular datos de manera dinámica en nuestros programas.

Para resumir, los algoritmos y las variables, son conceptos fundamentales en la programación.

Los algoritmos definen la lógica de resolución de problemas, mientras que las variables nos permiten almacenar y manipular los datos necesarios para ese proceso. Juntos, forman la base de la creación de programas y aplicaciones de software.


cintillo_hive.png


cierre__post_Peakd.png

To read in English


cintillo_hive.png


Concepts of Logic of Programming N:1

Source/Source


cintillo_hive.png


First of all, warm greetings to the #Linux&Free Software community and to the entire #Linux community in #Hive, as we mentioned last Friday, in the post of the #Fridaydescritorio, we hope to start the PseInt software course next Friday.

But in order to advance and to be able to deepen in the management of the program, users must know certain terms and concepts, and instead of making a glossary, which was what I thought to do at the beginning, I decided to make a post and explain in a simple way and with examples, the most used concepts, in order to advance with a good theoretical base in the course.

To start, we are going to explain two concepts that are going to be widely used, not only in the course, but in the area of programming, which are the concepts of algorithm and variable.


What is an algorithm?


When we talk about an algorithm in the process of programming, we mean a well-defined and ordered sequence of steps, used to solve a specific problem.
That is, the algorithm, theoretically, is the basis of programming, since it allows programmers to create solutions through clear and logical instructions.


Algorithms are important for the following reasons:


  • They allow to standardize the problem solving in an efficient way.
  • They facilitate the understanding and maintenance of the code.
  • They help to identify and correct errors more easily.
  • They can be reused in different programs or situations.

Now we will use as an example a simple algorithm so that its operation is known:

We will make an algorithm to calculate the area of a rectangle:


Home:

Prompt the user to enter the base of the rectangle
Prompt the user to enter the height of the rectangle
Calculate the area by multiplying, the base by the height
Show the result of the area

The end


Let's take a step by step:


  1. Start: Marks the beginning of the algorithm.

  2. Prompt the user to enter the base of the rectangle: The user is prompted to provide the value of the base of the rectangle.

  3. Prompt the user to enter the height of the rectangle: The user is prompted to provide the value of the height of the rectangle.

  4. Calculate the area by multiplying the base by the height: The values provided by the user are taken and multiplied to obtain the area of the rectangle.

  5. Display the result of the area: The result of the calculation of the area is presented to the user.

  6. End: Marks the end of the algorithm.


This is a fairly simple example of what an algorithm is, it shows the basis of programming logic, since through the solution of algorithms, we teach a computer to act to solve a specific problem, in this case, it is to calculate the area of a rectangle.

As you can see, the steps of the algorithm are clearly defined, and thus can be easily passed to a programming language, to teach a computer how to calculate the area of a triangle, through a step by step.


Source/Source


What is a variable?


A variable, in the field of programming, is a space in the computer memory that is used to store and manipulate data. Some of the most common types of variables are:

  • Integers (int) - for whole numbers
  • Floating (float) - for numbers with decimals
  • Text strings (string) - to store text
  • Booleans (bool) - for values of true or false

Variables are important because:


  • They allow to store and process information dynamically.
  • They facilitate the organization and management of data in the program.
  • They make the logic of the program more flexible and adaptable.
  • They allow to easily reuse and modify the values during the execution.

Example of variables:


Suppose, we want to create a program that calculates the area of a circle, and in order to do that, we will need to store the value of the radius of the circle in a variable.

In our case we will do it at a practical level, using a pseudocode, in the PesInt program, but for this example, it would be something like:


Home

Declare a variable 'radius' of numeric type
Prompt the user to enter the value of the radius

Calculate the area of the circle using the formula: area = π * radius^2
Show the result of the area

The end


Let's analyze this example step by step:


  1. Declare a variable 'radius' of numerical type: Here we are creating a variable called 'radius' that will store a numerical value, which will be the radius of the circle.

  2. We ask the user to enter the value of the radius: We ask the user to enter the value of the radius of the circle he wants to calculate, whatever it is.

  3. Calculate the area of the circle using the formula: area = π * radius^2: Here we use the variable 'radius' containing the value provided by the user to calculate the area of the circle applying the corresponding formula.

  4. Show the result of the area: Finally, we show the user the result of the calculation of the area of the circle.

In this example, the variable 'radius' is fundamental to be able to perform the calculation of the area, without it, we could not obtain the value we need to apply the formula.

So, we must remember, that variables allow us to store and manipulate data dynamically in our programs.

To summarize, algorithms and variables are fundamental concepts in programming.

Algorithms define the logic of problem solving, while variables allow us to store and manipulate the data necessary for that process. Together, they form the basis of the creation of software programs and applications.


cintillo_hive.png


cierre__post_Peakd.png

Sort:  

¡Enhorabuena!


Has recibido el voto de PROYECTO CHESS BROTHERS

✅ Has hecho un buen trabajo, por lo cual tu publicación ha sido valorada y ha recibido el apoyo de parte de CHESS BROTHERS ♔ 💪


♟ Te invitamos a usar nuestra etiqueta #chessbrothers y a que aprendas más sobre nosotros.

♟♟ También puedes contactarnos en nuestro servidor de Discord y promocionar allí tus publicaciones.

♟♟♟ Considera unirte a nuestro trail de curación para que trabajemos en equipo y recibas recompensas automáticamente.

♞♟ Echa un vistazo a nuestra cuenta @chessbrotherspro para que te informes sobre el proceso de curación llevado a diario por nuestro equipo.


🏅 Si quieres obtener ganancias con tu delegacion de HP y apoyar a nuestro proyecto, te invitamos a unirte al plan Master Investor. Aquí puedes aprender cómo hacerlo.


Cordialmente

El equipo de CHESS BROTHERS

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.