
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10400 Articles for Python

991 Views
There are numerous situation occurs when we want our program to do this specific task, irrespective of whether it runs perfectly or thrown some error. Mostly to catch at any errors or exceptions, we use to try and except block.The “try” statement provides very useful optional clause which is meant for defining ‘clean-up actions’ that must be executed under any circumstances. For example −>>> try: raise SyntaxError finally: print("Learning Python!") Learning Python! Traceback (most recent call last): File "", line 2, in raise SyntaxError File "", line None SyntaxError: The final clause ... Read More

209 Views
Here we are trying to do two tasks at a time, one in the foreground and the other in the background. We’ll write something in the file in the background and of a user input number, will find if it’s an odd or even number.Doing multiple tasks in one program in python is possible through multithreading in Live Demoimport threading import time class AsyncWrite(threading.Thread): def __init__(self, text, out): threading.Thread.__init__(self) self.text = text self.out = out def run(self): f = open(self.out, "a") f.write(self.text + '') ... Read More

33K+ Views
FunctionA function is a block of code to carry out a specific task, will contain its own scope and is called by name. All functions may contain zero(no) arguments or more than one arguments. On exit, a function can or can not return one or more values.Basic function syntaxdef functionName( arg1, arg2, ...): ... # Function_body ...Let's create our own (user), a very simple function called sum (user can give any name he wants). Function "sum" is having two arguments called num1 and num2 and will return the sum of the arguments passed to the function(sum). When ... Read More

2K+ Views
We will display duplicates from a list of integers in this article. The list is can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that the items in a list need not be of the same type Let’s say we have the following input list − [5, 10, 15, 10, 20, 25, 30, 20, 40] The output display duplicate elements − [10, 20] Print duplicates from a list of integers using for loop We will display the duplicates of a list of integer using a for loop. We ... Read More

20K+ Views
This is a python program to print all the numbers which are divisible by 3 and 5 from a given interger N. There are numerous ways we can write this program except that we need to check if the number is fully divisble by both 3 and 5.Below is my code to write a python program to print all the numbers divisible by 3 and 5 −lower = int(input("Enter lower range limit:")) upper = int(input("Enter upper range limit:")) for i in range(lower, upper+1): if((i%3==0) & (i%5==0)): print(i)OutputEnter lower range limit:0 Enter upper range limit:99 0 15 ... Read More

1K+ Views
What is an iterable? An iterable can be loosely defined as an object which would generate an iterator when passed to inbuilt method iter(). There are a couple of conditions, for an object to be iterable, the object of the class needs to define two instance method: __len__ and __getitem__. An object which fulfills these conditions when passed to method iter() would generate an iterator. Iterators Iterators are defined as an object that counts iteration via an internal state variable. The variable, in this case, is NOT set to zero when the iteration crosses the last item, instead, StopIteration() is ... Read More

14K+ Views
Dynamic ArrayIn python, a list, set and dictionary are mutable objects. While number, string, and tuple are immutable objects. Mutable objects mean that we add/delete items from the list, set or dictionary however, that is not true in case of immutable objects like tuple or strings.In python, a list is a dynamic array. Let's try to create a dynamic list −>>> #Create an empty list, named list1 >>> list1 = [] >>> type (list1) Add some items onto our empty list, list1 −>>> # Add items >>> list1 =[2, 4, 6] >>> list1 [2, 4, 6] >>> # Another way ... Read More

376 Views
Python provides various libraries to handle geographical and graph data. Python plotly is one of those libraries which are used to draw geographical graphs. Plotly is a free and open source library. Plotly helps to plot various kinds of graphs like Line charts, Horizontal bar charts, bar charts, dashboards, scatter plots, bubble charts, pie charts and many more.# Import important python geographical libraries. import plotly.plotly as py import plotly.graph_objs as go import pandas as pd # Must enable in order to use plotly off-line. from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, plot # To establish connection init_notebook_mode() # type defined is ... Read More

3K+ Views
For data analysis, Exploratory Data Analysis (EDA) must be your first step. Exploratory Data Analysis helps us to −To give insight into a data set.Understand the underlying structure.Extract important parameters and relationships that hold between them.Test underlying assumptions.Understanding EDA using sample Data setTo understand EDA using python, we can take the sample data either directly from any website or from your local disk. I’m taking the sample data from the UCI Machine Learning Repository which is publicly available of a red variant of Wine Quality data set and try to grab much insight into the data set using EDA.import pandas ... Read More

22K+ Views
There are multiple ways by which we can add packages to our existing anaconda environment.Method 1 − One common approach is to use the “Anaconda Navigator” to add packages to our anaconda environment. Once “Ananconda Navigator” is opened, home page will look something like −Go to Environments tab just below the Home tab and from there we can check what all packages are installed and what is not.It is very easy to install any package through anaconda navigator, simply search the required package, select package and click on apply to install it. Let's suppose tensorflow packages are not installed in ... Read More