filmov
tv
Python for Beginners: 11. For Loop vs While Loop in Python

Показать описание
#python #for #while #forloop #whileloop #python #programming #tutorial #beginners
About this Video:
This video covers difference between a for loop and a while loop in Python using example codes and flow-chart. This video is a part of Episode 09, and is posted as a separate video here at the request of the viewer(s).
in Python, there are 2 ways to create loops if we want to re-use a block of code. We can either use a “for-loop” or a “while-loop”.
If we have a block of code that needs to be repeated a predefined number of times, then we will use a for-loop. In order words, for-loop is a finite loop that iterates for known number of times before it stops.
Link to tutorial video of For-Loop:
On the other hand, a while-loop iterates until a stop-condition is met. In other words, if we need our code to be repeated while an exit-condition has not been reached, we will use a while-loop. A typical example is a game-loop that keeps running for hours or days until user wants to terminate the game.
Link to tutorial video of While-Loop:
Find this video helpful? Please Like, Share and Subscribe
Timestamp:
0:00 Welcome Brief
0:42 For-Loop vs While-Loop
1:28 For-Loop and While-Loop in a single line
2:20 While-Loop and For-Loop to get a multiplication table
4:22 Nested While-Loop and Nested For-Loop to get multiplication tables
8:35 Recap/ Summarization
About this Video:
This video covers difference between a for loop and a while loop in Python using example codes and flow-chart. This video is a part of Episode 09, and is posted as a separate video here at the request of the viewer(s).
in Python, there are 2 ways to create loops if we want to re-use a block of code. We can either use a “for-loop” or a “while-loop”.
If we have a block of code that needs to be repeated a predefined number of times, then we will use a for-loop. In order words, for-loop is a finite loop that iterates for known number of times before it stops.
Link to tutorial video of For-Loop:
On the other hand, a while-loop iterates until a stop-condition is met. In other words, if we need our code to be repeated while an exit-condition has not been reached, we will use a while-loop. A typical example is a game-loop that keeps running for hours or days until user wants to terminate the game.
Link to tutorial video of While-Loop:
Find this video helpful? Please Like, Share and Subscribe
Timestamp:
0:00 Welcome Brief
0:42 For-Loop vs While-Loop
1:28 For-Loop and While-Loop in a single line
2:20 While-Loop and For-Loop to get a multiplication table
4:22 Nested While-Loop and Nested For-Loop to get multiplication tables
8:35 Recap/ Summarization