
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

275 Views
Python has the capability to process the HTML files through the HTMLParser class in the html.parser module. It can detect the nature of the HTML tags their position and many other properties of the tags. It has functions which can also identify and fetch the data present in an HTML file.In the below example we see how to use the HTMLParser class to create a custom parser class which can only process the tags and data that we define in the class. Here we are processing the start tag, end tag and data.Below is the html which is getting processed ... Read More

12K+ Views
Python is very good at handling API calls. In this article we will see how we can handle the API calls for currency exchange rates in real time as well as historical.Using forex-pythonThis module provides the most direct way of getting the currency conversion rates. It has functions and parameters which can take inputs for the required currency codes and then give the result for the conversion. The below example gives the live conversion rate.Examplefrom forex_python.converter import CurrencyRates c = CurrencyRates() print(c.get_rate('USD', 'GBP'))OutputRunning the above code gives us the following result −0.7357387755Historical currency ratesWe add a datetime object ... Read More

6K+ Views
Rotating a matrix in python, can be done by utilizing various approaches like Transpose and Reverse method which is commonly used in rotating a matrix by converting the rows to columns and columns to rows. Common Approaches Some of the common methods, we can use to rotate a matrix by 90 degress clockwise are as follows. Layer by Layer Rotation Temp Matrix Method Transpose and reverse 2D ... Read More

301 Views
Suppose we have the preorder traversal of a binary search tree (BST). We have to check whether each internal node has only one child or not.So, if the input is like preorder = [22, 12, 13, 15, 14], then the output will be True as BST is like −To solve this, we can follow one efficient approach. As all decedents of a node is either smaller or larger, then we can we can follow these steps −Get the next preorder successor of the nodeGet the last preorder successor of the nodeNow when both the successors are less than or greater ... Read More

269 Views
Suppose we have two numbers x and y. We have to check whether difference of their areas is prime or not.So, if the input is like x = 7, y = 6, then the output will be True as the difference of their square is 49 - 36 = 13 which is prime.To solve this, we will follow these steps −if (x + y) is prime number and (x - y) is 1, thenreturn Trueotherwise,return FalseLet us see the following implementation to get better understanding −Example Live Demodef is_prime(num) : if num

199 Views
Suppose we have one octal number. We have to check whether the decimal representation of the given octal number is divisible by 7 or not.So, if the input is like n = 61, then the output will be True as the decimal representation of 61 is 6*8 + 1 = 48 + 1 = 49 which is divisible by 7.So, if the input is like n = 61, then the output will be True as the decimal representation of 61 is 6*8 + 1 = 48 + 1 = 49 which is divisible by 7.To solve this, we will follow ... Read More

832 Views
Suppose we have a number n, we have to find its total number of divisors are even or odd.So, if the input is like n = 75, then the output will be Even, as the divisors are [1, 3, 5, 15, 25, 75].To solve this we shall follow one simple and efficient approach. We have observed that when a number is perfect square then only it has odd number of divisors. So if the number is not perfect square then it will have even divisors. So here we will only check whether the number is perfect square or not and ... Read More

367 Views
Suppose we have two bracket sequences s and t with only these characters '(' and ')'. We have to check whether the concatenated string of s and t is balanced or not. The concatenation can be done by s | t or t | s.So, if the input is like s = "()()))", t = "()(()(", then the output will be True because if we concatenate t | s, then we will get "()(()(()()))", which is balanced.To solve this, we will follow these steps −Define a function is_balanced_parenthesis() . This will take stringstack := a new listfor i in range ... Read More

178 Views
Suppose we have two strings s and t, we have to check whether we can generate t by swapping the character of the s.So, if the input is like s = "worldlloeh" t = "helloworld", then the output will be True as we can swap characters from "worldlloeh" to make "helloworld".To solve this, we will follow these steps −s_len := size of s, t_len := size of tif s_len is not same as t_len, thenreturn Falsefreq := a map to store all characters and their frequencies in sfor i in range 0 to t_len, dofreq[t[i]] := freq[t[i]] - 1if freq[t[i]] ... Read More

1K+ Views
Suppose we have a string s, we have to check whether characters of the given string can be shuffled to make a palindrome or not.So, if the input is like s = "raaecrc", then the output will be True as we can rearrange this to "racecar" which is a palindrome.To solve this, we will follow these steps −freq := a map to store all characters and their frequencies in sodd_count := 0for each element i in the list of all values of freq, doif i is odd, thenodd_count := odd_count + 1if odd_count > 1, thenreturn Falsereturn TrueLet us see ... Read More