python control flow and functions

Certainly! Here’s a cheat sheet for Lesson 2: Control Flow and Functions:

Control Flow:

x = 10
if x > 5:
    print("x is greater than 5")
elif x == 5:
    print("x is equal to 5")
else:
    print("x is less than 5")
# for loop
for i in range(5):
    print(i)

# while loop
x = 0
while x < 5:
    print(x)
    x += 1

Functions:

def function_name(parameters):
    # function body
    return value
def greet(name):
    return "Hello, " + name + "!"

print(greet("Alice"))

Notes: