🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!
🖥️ Python WHILE Loops (Iterators in Python) - Definition and Syntax
Loops in Python are an efficient method for optimising your code, and executing multiple statements. If the same block of code has to be executed, multiple times, over and over: you can put it into a loop, to perform multiple iterations, and get the same desired output. Consequently: it saves a lot of effort, and reduces complexity of the code, as well.
Basically, there are two types of iteration in programming languages:
Indefinite iteration: In which the code block executes, until some condition is met. This iteration is performed using WHILE Loops in Python, and will be discussed in the next section.
Definite iteration: In which the number of repetitions is specified, explicitly - and in advance. This kind of iteration is performed using for loops, and has been discussed in the previous video
--
The WHILE statement in Python is a bit different from what you usually use, in other programming languages. Rather than iterating over a numeric progression, or over the items of an iterable, like: strings, dictionaries, lists, tuples and sets - or any other iterable objects.
WHILE loops are traditionally used when you have a block of code which you want to repeat indefinitely, and as long as an expression is True - or a particular condition is met. And you generally use this loop when you do not know beforehand how many iterations are going to take place.
Do not forget to contrast the WHILE statement with the FOR loop in Python - which is used when you want to repeat a block of code, for a fixed number of times. Okay, But what does it look like, and how to control the execution flow of your program, using while loops? Let's move forward, and have a look at the syntax of the while statement.
○ WHILE Loop Syntax
while condition:
statement_1
statement_2
...
Here, is a simple declaration of a WHILE Loop in Python. First, the execution starts and checks whether the condition is True. When the condition is True, it enters the while loop - and executes the indented statements, inside the while loop. After one iteration, the condition is checked again. And this process continues until the condition evaluates to False. As soon as the condition is False, its execution skips the while loop, and moves to the next following statements in the program.
Please also note that Python interprets any non-zero value or non-empty container as True. Consequently, None, zero and empty sequence will be interpreted as False. And if the condition is False at the start, the while loop will never be executed.
Let's play this video, stick around and watch until the end of this video! 👍🏻
Digital Academy™ 🎓
***
☞ WATCH NEXT:
○ Data Types in Python - • DATA TYPES in Python (Numbers, Strings, Li...
○ Operators in Python - • OPERATORS in Python (Arithmetic, Assignmen...
○ IF Statements in Python - • CONDITIONAL Statements in Python (IF, ELIF...
○ FOR Loops in Python - • FOR Loop in Python (Syntax, Break, Continu...
📖 Blog: http://digital.academy.free.fr/blog
📖 [FULL Course] HOW TO Learn Python? Python Tutorial for Beginners: • 🐍 Python 101: Learn Python Basics for Abso...
📖 [PLAYLIST] Complete Python Development Course for Beginners: http://digital.academy.free.fr/playli...
🧑🎓 [COURSE] http://digital.academy.free.fr/courses
📘 [BOOK] Python for Absolute Beginners: https://amzn.to/3NvyOWV
🛒 Shopping and Discounts: http://digital.academy.free.fr/store
💌 Weekly Newsletter for Developers: https://www.getrevue.co/profile/digit...
#Python #Tutorial #Beginners #Shorts
***
♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.
***
♡ FOLLOW US ♡
✧ http://digital.academy.free.fr/
✧ / digitalacademyy
✧ / digitalacademyfr
✧ / digital_academy_fr
✧ / digitalacademyonline
♡ SUPPORT US ♡
✧ http://digital.academy.free.fr/join
✧ http://digital.academy.free.fr/store
✧ http://digital.academy.free.fr/donate
✧ http://digital.academy.free.fr/subscribe
✧ / digital_academy
✧ https://www.buymeacoffee.com/digital_...
***
Auf dieser Seite können Sie das Online-Video WHILE Loops in Python: Definition & Syntax - Python Tutorial for Beginners mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Digital Academy 05 März 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 450 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!