How to use IF Statement in Python ?

In this article, we are telling you about IF Statement in Python, if you also want to go, how to use IF Statement in Python, in such a way you can read this article, we are telling you practically everything here.

Here before going about IF Statement in Python, you must know that if statement is used in almost all programming languages ​​as well as it is also used in creating Hacking tools.

When you create some kind of program to check some kind of condition, in this case the IF Statement in Python is used, so you must know about it, here we are also telling you the use of others.

Also Read

How to Create Hacking tools in python ?

String Formatting and String Slicing in Python

How to use INT Function in Python ?

Why We use IF Statement in Python ?

Before using IF Statement in python, you should know why and when IF Statement is used as you are told to use IF Statement to check the condition.

Let’s try to understand this by example, as if you have to print the user’s age, in such a way, you want that if the age of the user is 25 or more, then it should be printed only if the user’s age is below 25 such I should not print

To do all this, the IF Statement is used in python, in the same way you use else as if the user’s age is 25 or more, you should print if you are above 25 and if the user’s age is less than 25 such I should print you are under 25

Similar nested if-else can also be used, here we are telling you using IF statement in python and else statement as well as you are also being told to use pass statement here.

Use of IF Statement in Python ?

Let us now know how to make use of IF statement in python, we have created this program, here you can see in the image that IF statement in python is used in this way.

IF Statement in Python

As you can see in the program, the user is first asked the age here, if the age is 25 or more, then only the print function works if the user indicates age less than 25, in such case the print function does not work.

Here you must know one thing: Use the print function, you can write anything in as many lines as you want, but it works only when the condition is true as we have printed you are above 25 such lines as you want. can print

Here the space that you are seeing after the if statement here also has its importance as we know that in other programming languages ​​we use curly brackets but in python the spaces of those same curly brackets are used.

IF Statement in Python

Here if you do not use the space, in such a situation you get an error in your program. This space is automatically created as soon as you use the IF Statement in python, here you should never remove them as you can see in the image.

Pass Statement in Python?

We use the pass statement with the if statement itself, as if you have been told to use the IF statement in python, just like this pass statement is used in python, let’s understand it by example.

As you have been told in the IF Statement in python, the print function works when the condition is true, just like if we do not want to use the print function, in such a way we use the pass statement in the program as you can see in the image.

If-Else statement in Python ?

In this way you can use else statement with if statement, as you can see in the image, in this way if -else statement is used together in python, you can also try to create a similar program.

Here, as we are printed when age is more than 25, you are above 25; If you are under 25, we have got printed in the program, you are under 25, the same nested if -else is also used.

Here, you should always keep in mind that if the user has given more than 25 years of age, then the program runs as far as is needed, as if the user has given 27 years, in such a situation the program will run only and in the output you are above 25 print

The program does not go until else, unless there is a need, just like if the user gives less than 25 years of age, then the program goes to the other, so even if you make some kind of mistake in others, you still do not get the error.

As you can see in the image, even a small mistake in python gives you an error, in such a way you should always write your program correctly, as in the image you can see else we have made a mistake in such an error was not found.

This is because the program does not need to go to else, but if the program runs until else, if you make some kind of mistake, you definitely get an error, something like this if statement in python is used.

The Conclusion

I hope now you can understand about the IF Statement in Python. Here we have told you practically about how to use the pass statement, If -else statement.

We have told you this earlier in the article of how to create hacking tools like that while loop, for loop has been used, similarly IF statement in Python is also used in many types of programs.

The more you learn Python programming language the better it is for you. If you learn Python deeply, you can also understand about hacking tools created by others as well as create your own tools.

Here you can find many articles related to ethical hacking like facebook hacking, whatsapp hacking, phishing scam, spamming and scam pages, you can also read our article if you want.

If you face any kind of problem in the IF Statement in Python, then you can ask in the comments, we will help you completely, you like our article, in such a way, share it for updates Subscribe to our blog.

Sharing is Caring

Thankyou

Be the first to comment

Leave a Reply

Your email address will not be published.


*