Introduction to if Statements
if
if condition: # code block runs if condition is True
x = 10 if x > 5: print("x is greater than 5")
x is greater than 5
{}
if True: print("This will run") print("So will this") print("This is outside the if")
if True: print("Oops, no indent!") # error
Try it yourself:
age = int(input("Enter your age: ")) if age >= 13: print("You are a teenager or older!")
Write code that:
"Even!"
else