Post a tweet to Twitter using python

In our last article we have seen how to get our followers and following list and write those names to an excel sheet. If you have not read the article please go and have a look. In this article we are going to tweet from python using the “twitter-python”. The prerequisites and the steps to […]

Read More

Convert audio files to graph visualisation

In this article we shall how we can convert an audio file to its graph visualisation. The graph is plotted by taking the frequencies of the audio file as a numpy array. Let us get started. Libraries needed We will need the following two libraries for this task. soundfile matplotlib both can be installed via […]

Read More

**kwargs in python

**kwargs is used when we want to pass variable length keyworded arguments to a function. A keyworded arguments will have a key value pair like name=”John” or {“name”:”John”}. Let us look into **kwargs with two examples. In the first example we will pass keyworded arguments of variable length. In the next example we will pass […]

Read More

*args in python

Whenever there is any function that accepts arguments, the number of arguments passed while calling the function should always match the number of arguments in the function. If we violate this the code throws an error. Let us look at this with a simple example. Consider the following code. This will print 10 as the […]

Read More

Pass, break and continue in python

Pass Whenever we use any loops in python, try except statements or functions, it expects something to be on the next line. This is the general syntax of statements like these. Nothing happens when pass is executed. Its main purpose is to act as a placeholder where the interpreter expects a statement. Remember a colon-separated compound statements needs a header and a […]

Read More

String methods in python

Strings in Python provide a number of methods. Let’s have a look at them. These following 10 methods are explained in detail with an example for each. strip whitespaces replace substrings manipulate cases split strings join words isaplha(), isnumeric() occurrences of a substring where is the substring? endswith string formatting 1. Strip whitespaces The following […]

Read More

Download profile pictures from Instagram using python

In some cases, we all would have wanted to download the profile picture of a person from Instagram. On Instagram we can only be able to see the profile picture of a user as a very small thumbnail. What if we could view the profile picture of the user and even save it? Python let […]

Read More

Ternary operator in python

Ternary Operators Ternary Operators are your classic if-then-else statements, but expressed in a single line. For example: Can be translated to: Syntax An if-then-else statement MUST have an else argument, otherwise your code will crash. You can also nest these statements; however, it is best practice to simply write the if statements separately if you have more than one expression.

Read More

__str__() in python – what and why it is used?

What is the use of __str__() in python? This is very similar to the toString() method in Java for an object. Thus if you override the __str__ method inside a class definition in Python, you get the see the friendly name of the object. Let me show you an example code Initially we had the Person class with nothing […]

Read More