if-statement can be considered as the backbone of programming!! This is where all the logic begins. In simple terms, if some condition is met, then perform certain set of actions, otherwise do nothing.
1 2 3 4 5 6 7 8 9 10 11 |
# Creating a variable x=10 # Do something only if the condition is true if(x>5): print("condition is true!") # creating another variable y=100 print(y) |
Sample Output:

1 2 3 4 5 6 7 8 9 10 11 |
# Creating a variable x=10 # if the condition is false then nothing will happen if(x>50): print("condition is true!") # creating another variable y=100 print(y) |
Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!