Flow control

This Python recipe includes:

  • If-Then-Else conditions
  • For-loops
  • While-loops

Let’s get started.


If-Then-Else conditions


speed = 90
if speed == 90:
    print('Speed is high')
elif speed > 160:
    print('Speed is too high')
else:
    print('Speed is safe')
Speed is high

For-loops


for i in range(6):
    print(i)
0
1
2
3
4
5

While-loops


count = 0
while count <= 5:
    print(count)
    count += 1
0
1
2
3
4
5

Leave a Reply

Your email address will not be published. Required fields are marked *