Python - While Loop Tutorial with Examples - APPFICIAL

Publicado em: 28 Setembro 2021
no canal de: Appficial
3,500
18

A while loop is a pre-test loop that executes its body of code repeatedly while the loop's expression evaluates to true. Once the expression is false, the loop ends and your Python program continues with the next statement outside the loop.

An iteration is one execution of the loop body. A loop variable counts the number of loop iterations and is typically used to control the loop.

A sentinel value may optionally be used to control the end of the loop. This is helpful for interactive programs, where you ask the user to type q to quit.

You use loops everyday. For example, when you are eating a sandwich, you may look at it and ask yourself “Is there more sandwich?”, and “Am I still hungry?”. If both conditions are true, then you’d take another bite. If you weren’t hungry, you’d stop the eating loop. If you had no sandwich left, but were still hungry, then you’d have to stop the eating loop too, otherwise you’d bite your hand off.

Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!


Nesta página do site você pode assistir ao vídeo on-line Python - While Loop Tutorial with Examples - APPFICIAL duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Appficial 28 Setembro 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 3,500 vezes e gostou 18 espectadores. Boa visualização!