Home / Python Statement / How to Write an If Statement Using If Keyword in Python In this example we will show how to write an if statement using the if keyword in Python. Source Code x = 20 y = 8 if x > y: print('x is greater than y') Output: x is greater than y