if else in python

If else in python | Full tutorial for beginners


In this post, you will learn the if and else statement in python and how does it work and we will see some examples using the if / else statement and below is the video format of the post, check it out ????????


What is if/else in python ????

To explain if and else, let’s take a real example.

Let’s take a roller coast ride the boy or girl below 80 cm are not allowed to go for the ride. But if they are above 80cm they are allowed for the ride.

So, If we put this in a programming language,

If height > 80:



print(“not allow”)

So, the if statement says if the boy or girl is 80cm above then they are allowed nor the else statement not allows.

if condition:

do this


do this

if else in python

So, above is a simple chart on how does the if / else statement works and I hope you understood if not comment down below. I will help you out ????????

Real-life if / else example

Let’s take a real-life example as the roller coast ride itself and in this example, we are going to write it in a more meaningful format.

Our main aim is if the height is below 80 cm they are not allowed for the ride. But if they are above they are allowed.

You may ask there may be a person and he would find who is not eligible but we are going on digital evolution and just a piece of code like the below can stop or allow for the ride.

However, This particular below code will save giving salary for the person who is watching the eligibilities.

Just be free to try this example.

The result will be something like this ????????

if else in python

By the way, Now you should be familiar with the if and else statement and in the next post. We will see how does the elif statement work.

Also Read: Number manipulation in python

Also Read: F-string in python full tutorial

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions or brave browser to block ads. Please support us by disabling these ads blocker.Our website is made possible by displaying Ads hope you whitelist our site. We use very minimal Ads in our site


Scroll to Top