Today I will introduce to an important topic in Computer Science and that is Sorting, I will try to explain as easy as I can for user understanding. We will also be explaining 2 related algorithms that make our work more easier but be aware that I’ve written the Algorithm code in Python 3.3 so be sure to have a Python understanding. So first lets see what Sorting is?
I though that instead of using others made tools to find out hosts which are online in a given IP range, I should rather make my own with python.
UPDATED: Updated the script, it no longer takes ip as an input, Instead get the IP and starts scanning the in the possible given range it self. You need to download the Ping.py file from the github repo to be able to run the script.
Python comes built-in with many functions, some of those functions allow us to read a file and write to a file. The step involved in reading a file is to open it and afterwards read it’s contents, then either store it in a variable or print it directly.
To open a file in python we use the function open() , The syntax for open function is:
In programming, most of the time we come across a stiff situation where we are required to do one or more task depending on the output of the first most task. Lets take an example of a simple program which give the output a set of even numbers between 1 to 20.
Now we want this program to only view all the even numbers only but first lets see what conditionals are and how many types are there in Python. Well In Python there are 3 Basic Conditionals statements:
1) If Condition
2) Else If Condition
3) Else Condition
Here’s a little diagram to demonstrate how the conditional statements work:
While making programs, one thing a programmer must keep in mind is how to handle unexpected errors. Errors can some time be very frustrating and must be handled in a correct way so that the user understands what caused this error and why? In python there’s an easy way to do it.
To understand error exception, we will make use of a sample program, the program asks the user to input his/her age so here’s the code: