
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 10476 Articles for Python

60K+ Views
In this tutorial, we are going to find the IP address of the client using the socket module in Python. Every laptop, mobile, tablet, etc.., have their unique IP address. We will find it by using the socket module. Let's see the steps to find out the IP address of a device.Algorithm Import the socket module. Get the hostname using the socket.gethostname() method and store it in a variable. Find the IP address by passing the hostname as an argument to the socket.gethostbyname() method and store it in a variable. Print the IP address. Let's write code for the above ... Read More

6K+ Views
We have a list of strings and our goal is to sort the list based on the length of strings in the list. We have to arrange the strings in ascending order according to their lengths. We can do this using our algorithms or Python built-in method sort() or function sorted() along with a key.Let's take an example to see the output.Input: strings = ["hafeez", "aslan", "honey", "appi"] Output: ["appi", "aslan", "honey", "hafeez"]Let's write our program using sort(key) and sorted(key). Follow the below steps to achieve the desired output using a sorted(key) function.Algorithm1. Initialize the list of strings. 2. Sort ... Read More

203 Views
In this tutorial, we are going to sort a list of tuples in increasing order by nth index key. For example, we have a list of tuples [(2, 2), (1, 2), (3, 1)] then, we have to sort it using 0th index element. The output for that list would be [(1, 2), (2, 2), (3, 1)].We can achieve this by using the sorted method. We have to pass a key while giving the list to the sorted function. Here, the key is the index on which the sorting is based.sorted takes a list and returns that list in ascending order ... Read More

19K+ Views
We are given a string, and our goal is to reverse all the words which are present in the string. We can use the split method and reversed function to achieve the output. Let's see some sample test cases.Input: string = "I am a python programmer" Output: programmer python a am IInput: string = "tutorialspoint is a educational website" Output: website educational a is tutorialspointLet's follow the below steps to achieve our goal.Algorithm1. Initialize the string. 2. Split the string on space and store the resultant list in a variable called words. 3. Reverse the list words using reversed function. ... Read More

778 Views
Google Colaboratory is a free Jupyter notebook environment that requires no setup and runs entirely in the cloud. It is hosted in google cloud and maintained by Google for the benefit of python coders who want to run and test python scripts using a cloud environment. In this article, we will see how to set up and run a google collaboratory cloud environment.Opening the Python NotebookWe navigate to this google link (https://colab.research.google.com/). It opens up the below screen. We choose the option NEW PYTHON3 NOTEBOOK from the bottom right corner as shown in the diagram below.Python CodeOptionsOn clicking the NEW ... Read More

272 Views
Dictionaries in python are a type of data structure that map keys to values as a key-value pair. They are one of the frequently used data structures and have many interesting properties. They are presented by enclosing them in a pair of curly brace like below.dict = {'day1':'Mon' ,'day2':'Tue', 'day3':'Wed'}The elements or key-value pairs in the dictionary are represented within single quotes and separated by a colon.Creating a DictionaryWe create a dictionary by assigning values written in the form of a key.ExampleDict1 = {'day1':'Mon' ,'day2':'Tue', 'day3':'Wed'} print(type(dict1)) print(dict1) # Using the dict() method dict2 =dict({('day1', 'Mon'), ('day2', 'Tue'), ('day3', ... Read More

298 Views
Heap queue is a special tree structure in which each parent node is less than or equal to its child node.In pythin it is implemented using the heapq module. It is very useful is implementing priority queues where the queue item with higher weightage is given more priority in processing. TheCreate a HeapA heap queue is created by using python’s inbuilt library named heapq. This library has the relevant functions to carry out various operations on heap data structure. Below is a list of these functions.heapify − This function converts a regular list to a heap. In the resulting heap ... Read More

635 Views
Get MongoDBTo install MongoDB on Windows, first, download the latest release of MongoDB from https://www.mongodb.org/downloads. Below is an example of selecting a 64-bit version for windows as a msi installer.Install MongoDBNext, we follow the below steps to install MongoDB. As it is a windows installation using the msi installer, the steps are very straight forward. We choose a complete installation instead of a custom installation.Running the installerHere we run the installer which has been downloaded to our system. The installation starts asking for various steps of confirmation.Choosing a Service ConfigurationWe choose to run the service as a network service user. Clicking ... Read More

1K+ Views
Python has the ability to create graphs by using the matplotlib library. It has numerous packages and functions which generate a wide variety of graphs and plots. It is also very simple to use. It along with numpy and other python built-in functions achieves the goal. In this article we will see some of the different kinds of graphs it can generate.Simple GraphsHere we take a mathematical function to generate the x and Y coordinates of the graph. Then we use matplotlib to plot the graph for that function. Here we can apply labels and show the title of the ... Read More

932 Views
Different variables in a python program have different scope. Depending on where it is declared, the variable may or may not be accessible inside a function. Sometimes we will need to modify a variable that is present inside a function from outside its current scope. In such a scenario we use the global keyword with the variable name.Following are the key points about the global keywordA variable declared outside a function is a global variable by default.We use a global keyword for a variable which is inside a function so that it can be modified.Without the global keyword, the variable ... Read More