Expression “[n for n in range(10) if n%2]” will return a list in one go. This creates a list of odd numbers between 0 and 9. The for loop goes from 0 to 9 and the number which is not …
An array is basically a data structure which can hold one value at a time. It is a collection or ordered series of elements of the same type. Many of us gets confused whether list and arrays are the same …
Excel file is a spreadsheet which makes us easy to store data in a tabular form. Now the question is that how can we read data from the excel file while writing a python program? Firstly, we have to install …
We can compare two strings in python by comparison operators. There are many comparison operators like ‘==’, ‘!=’, ‘>’, ‘<‘, etc. String comparison in python takes place character by character. == – It checks whether two strings are equal. != …
Python comes with a built-in random library. It has got lots of functions included with this library such as choice, randint etc. For generating a random number in python firstly we have to import a module random. E.g., In this …
In any programming language, printing output is a most important task. In python also printing output is the most important task. Printing output in the same line is also a task in python. We have some methods by which we …
As we all know that there is no in-built function to clear the screen in python. But sometimes it becomes very necessary to clear the screen. In the interactive python shell we can clear screen it by pressing “control + …
When you are writing a program it is necessary that your program is easily readable and easy to understand by others. An easy way to increase the readability of the program is to use comment. Multiline comment is a type …
Class based functions include a reference to self so that you can know which class instance called it. It represents the instance of the class. It is not a keyword in python. We can access attributes and methods of class …
You have to install python before starting to work in it. There are multiple ways and different versions of python available today. When you are done with the installing process of python you can run your program in the following …