Popular Posts

Friday, August 28, 2020

Python Beginner: While Loop

 Hello, developer!


Have you made your own dictionary for your abbreviation?

Today, we will learn the "While Loop". "While Loop" enables you to repeat execution of some codes while the condition is "True". While loop executes indented codes repeatedly until condition result is "False". 


I shows "While Loop" declaration and form as below. 

While Loop declaration 

While condition:

        execution codes # Indented codes will be repeated until condition result is "False"


Following exercise program is a good example in order to understand how works "While loop" in Python. I showed all exercise codes and execution result as following.

i = 1
while i<=10: # Check the condition result is "True"
print(i)
i += 1 # Add 1 to variable "i" and input calculated value into variable"i"
# Back to while line and check the condition
print("Done with loop")

Can you see the same result? Great job! Now you can use "While loop" in the Python program. 

Let's see on next post, developer! 😊

No comments:

Post a Comment

Python - Web crawling exercises

Hello Python developer! How are you? Hope you've been good and had wonderful time with Python. There are 10 Python requests module exerc...