Control Flow
Python supports the usual logical conditions from mathematics.
Conditional Statements
Section titled “Conditional Statements”If-Else
Section titled “If-Else”a = 33b = 200if b > a: print("b is greater than a")elif a == b: print("a and b are equal")else: print("a is greater than b")For Loops
Section titled “For Loops”A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
fruits = ["apple", "banana", "cherry"]for x in fruits: print(x)While Loops
Section titled “While Loops”With the while loop we can execute a set of statements as long as a condition is true.
i = 1while i < 6: print(i) i += 1