The control flow in Python is set by loops, conditional statements, and function calls.
if ... else
a = 50
b = 100
if a > b:
print('a is greater than b')
elif a < b:
print('a is smaller than b')
else:
print ('a is equal to b')
# a is smaller than b
Tip: In Python, spaces are the preferred indentation method, not tabs.
while loops
i = 4
while i < 10:
print(i)
i += 2
# 4
# 6
# 8
for loops
for x in "Python":
print(x)
# P
# y
# t
# h
# o
# n
Tip: for loops preferred over while loops.
If you like the content, please SUBSCRIBE to my channel for the future content.
To get full video tutorial and certificate, please, enroll in the course through this link: https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7
Top comments (0)