Python is available for various platforms which includes Linux, Windows and Mac OS. So here we are going to understand how to setup python environment. For the local environment setup open the terminal window and type there “python” to know that it is already installed or not, if installed then which version. Continue reading
As in Python it is not necessary to create our code into classes while developing program as we can use functions also which is known as Procedural Programming. However, a procedural programming is used for writing small, short and simple programs whereas object oriented programming (OOP) programs becomes more important as the programs grows in size and complexity. The Python has been the object oriented language since it is developed. Continue reading
Python offers several string replacement methods. Here we will cover two very useful methods. Continue reading
String concatenation is likely something you will need sooner or later. Python offers several possibilities to fulfill this task. Here we will present two of the most common methods. The first method is using the +-operator. The following snippet provides an example: Continue reading
In Python you can use the datetime module to work with dates and temporal data. A typical way to use it as such: Continue reading
Comparing dates (or datetime objects) in Python is very easy. The basic comparison operators (==, !=, <>, >, <, >=, <=) are overloaded for the datetime object, so comparing dates is very intuitive and quick. Continue reading
Sometimes we have to work with dates and times. I use dates less than times because with times you can measure code execution time which is sometimes essential (for my website scraping book’s performance measurement is the core part I guess). Continue reading
Now we arrived at object-oriented programming. This has (had) its hype where every language was designed around objects and Python developer Guido van Rossum thought “Why not?” and added classes to support object-oriented development. Some python evangelists think this was a bad decision, some think it was a good approach… Continue reading
We have seen this example previously. There I included a lot of loops to handle user input and the main logic… Now it is time to refactor the application to use functions. This should make the code readable and we could re-use parts later. Continue reading
Now we have learned the basics of Python programming: variables, collections and loops. If you have followed the examples and the tutorial you might feel that sometimes we use too much code and it can be leveraged a bit. But maybe you do not know how to do it.
Most of the time the solution is to introduce functions. We have encountered functions of other modules which we used just like isupper() of strings or choice() of the random module.
If you have learned mathematics then you know about functions already. Mathematicians can do very nasty things with them but programmers too. The aim of a function is to produce a result which is determined only by the parameters passed to the function. Continue reading