While
While
La instrucción while ejecuta una secuencia de instrucciones mientras una condición sea verdadera.
sintaxis
Ejemplo
Programa que pida al usuario una contraseña, de forma repetitiva mientras no introduzca “asd32”.
Cuando se escriba la contraseña correcta, se le dirá “Bienvenido”.
También existe la estructura do while
Lo que es único en los bloques do while es el hecho de que el código en el bloque del bucle se
ejecuta al menos una vez.
El código se ejecuta una vez primero y luego se verifica la condición. Si la condición marcada se
evalúa verdadera, el ciclo continuo.
Ejemplo
Conclusión
My conclusion from this topic is that in the While loop there are two types, the While and the Do
While, but the two have different functions, because the While structure the boolean condition is
evaluated before the code is executed while the Do While is first evaluated. executes the code
once (do) and then the condition is evaluated. We also observe another control structure which is
For, which is a loop that uses a counter, it is used to execute a block of code a defined number. We
also return to lists, which are the collection of several elements stored in a variable. A new concept
that I saw was Tuples that are the same as lists, only they cannot be changed, at the time of syntax
parentheses are used instead of square brackets.
Muñoz, J. D. (2023, julio 17). Estructuras de control repetitivas: while. PLEDIN 3.0.
https://plataforma.josedomingo.org/pledin/cursos/programacion_python3/curso/
u17/
https://www.freecodecamp.org/news/python-do-while-loop-example/