
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

13K+ Views
In this tutorial, we are going to learn how to print the calendar of month and year using the calendar module of Python. It's a straightforward thing in Python. We need year and month numbers. That's it.Let's see how to print a year calendar. Follow the below steps to print the year calendar.Import the calendar module.Initialize the year number.Print the calendar using calendar.calendar(year) class.ExampleSee the below code. Live Demo# importing the calendar module import calendar # initializing the year year = 2020 # printing the calendar print(calendar.calendar(year))OutputIf you run the above code, you will get the following output. ... Read More

855 Views
In this tutorial, we are going to learn how to multiply two matrices using the NumPy library in Python. It's straightforward with the NumPy library.It has a method called dot for the matric multiplication. You can install the NumPy library with the following command.pip install numpyLet's see the steps involved in the program.Import the NumPy library.Initialize the matrices.Multiply the matrices with numpy.dot(matrix_1, matrix_2) method and store the result in a variable.Print the result.See the below code.Example# importing the module import numpy # initializing the matrices matrix_1 = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ... Read More

2K+ Views
Given a list of numbers, move all the zeroes to the end using list comprehensions. For example, the result of [1, 3, 0, 4, 0, 5, 6, 0, 7] is [1, 3, 4, 5, 6, 7, 0, 0, 0].It's a single line code using the list comprehensions. See the following steps to achieve the result.Initialize the list of numbers.Generate non-zeroes from the list and generate zeroes from the list. Add both. And store the result in a list.Print the new list.Example# initializing a list numbers = [1, 3, 0, 4, 0, 5, 6, 0, 7] # moving all the zeroes ... Read More

4K+ Views
Google provides a static maps API that returns a map image on our HTTP request. We can directly request for a map image with different parameters based on our need.We have to create a billing account on Google to use this API. You can go to the website for more details.Let's see the steps to get the image of a location.Import the requests module.Initialise your API Key and base URL ("https://maps.googleapis.com/maps/api/staticmap?").Initialize the city and zoom value.Update the URL with API Key, City, and Zoom value.USend an HTTP request. And write the response to a file for saving the image.pdate the ... Read More

9K+ Views
In this tutorial, we are going to get the weather of a city using OpenWeatherMap API. To use the OpenWeatherMap API, we have to get the API key. We will get it by creating an account on their website.Create an account and get your API Key. It's free until 60 calls per minute. You have to pay if you want more than that. For this tutorial, the free version is enough. We need requests module for the HTTP requests and JSON module to work with the response. Follow the below steps to the weather of any city.Import the requests and JSON ... Read More

20K+ Views
In this tutorial, we are going to write a program that finds the frequency of all the elements in an array. We can find it in different ways let's explore two of them.Using dictInitialize the array.Initialize an empty dict.Iterate over the list.If the element is not in dict, then set the value to 1.Else increment the value by 1.Print the element and frequencies by iterating over the dict.ExampleLet's see the code.# intializing the list arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3] # initializing dict to store frequency of each element elements_count = {} ... Read More

626 Views
In this tutorial, we are going to write a program that counts and prints the words with a higher frequency of an alphabet than the second one.Take a string and two alphabets. The prefixes with a higher frequency of the first alphabet will be printed. And display the count at the end of the output.Let's see some examples.Inputstring:- apple alphabets:- p, eOutputap app appl apple 4Inputstring:- apple alphabets:- e, pOutput0Let's see the steps to write the code.Define a function and write the code in it.Initialize count to 0 and an empty string.Iterate over the string.Get the prefix using the string ... Read More

2K+ Views
Suppose we have a non-empty array of integer numbers. we have to return the kth most frequent elements. So if the elements are [1, 1, 1, 1, 2, 2, 3, 3, 3] and k = 2, then the result will beFormally the function should −Return true if there exists i, j, ksuch that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 else return false.To solve this, we will follow these steps −num_freq = an empty map, freq_list := an empty mapfor each element i in numsif i is not in num_freq, then num_freq[i] ... Read More

616 Views
Suppose there is an unsorted array. We have to check whether an increasing subsequence of length 3 exists or not in that array.Formally the function should −Return true if there exists i, j, ksuch that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 else return false.To solve this, we will follow these steps −small := infinity, big := infinityfor each element i in arrayif i

719 Views
Suppose we have a singly linked list, we have to group all odd nodes together followed by the even nodes. Here we are talking about the node position not the value in the nodes. We should try to do it in place. So if the nodes are [1, 22, 13, 14, 25], the result will be [1, 13, 25, 22, 14]To solve this, we will follow these steps −if head is null or the next of head is null, then return headhead1 := head, head2 := next of head, head_beg := next of headwhile next of head2 is nor null ... Read More