Condition
day = "sunday"
if day in ["sunday", "saturday"]:
print("Rest!")
elif day == "monday" and is_tired():
print("Groan!")
else:
print("Work!")
Example with try/except:
try:
result = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero!")
finally:
print("Cleanup complete.")
Loops
For loop example:
for i in range(5):
print(f"Iteration {i}")
While loop example:
count = 0
while count < 5:
print(f"Count is {count}")
count += 1