
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

177 Views
Suppose we have a matrix mat. There are few different values as follows The cells of matrix can hold any of these 3 characters0 for empty area.1 for bomb.2 for Enemies.Now bomb can blast in only horizontal and vertical directions from one end to another. We have to check whether all enemies will die when bomb explodes or not.So, if the input is like0020010002000010then the output will be True, because bomb at place [1, 1] can fill enemy at place [2, 1] and enemy at [0, 2] will be killed by bomb placed at [3, 2].To solve this, we will ... Read More

2K+ Views
Suppose we have a list of numbers nums. We have to check whether the list is palindrome or not.So, if the input is like nums = [10, 12, 15, 12, 10], then the output will be True.To solve this, we will follow these steps −n := size of numsreset is_palindromei := 0while i

682 Views
Suppose we have a number n. We have to check whether all digits of it can divide n or not.So, if the input is like n = 135, then the output will be True, because (135 / 1 = 135), (135 / 3 = 45) and (135 / 5 = 27).To solve this, we will follow these steps −val := nwhile val > 0, dod := val mod 10if n is not divisible by d, thenreturn Falseval := quotient of (val / 10)return TrueLet us see the following implementation to get better understanding −Example Live Demodef is_divisible(n, d) : return ... Read More

437 Views
In computers, data is stored in the binary form, which uses the two digits 0 and 1. Each digit in this format is known as a bit. In this article, we are going to check if all bits of a number are set in Python. A bit is said to be set if the binary representation of every bit is 1. Let's look at some scenarios to understand this better: Scenario 1 Input: 3 Binary: 111 Output: True Explanation: All bits are 1. Scenario 2 Input: 6 Binary: 110 Output: False Explanation: Not all bits are 1. ... Read More

161 Views
Suppose we have a string s of length 2, and also have a list of words w where all words are of length 2. We have to check whether we can concatenate words from w and that concatenated string contains s as substring or not.So, if the input is like s = "no", w = ["ol", "on", "ni", "to"], then the output will be True as we can concatenate strings like "onol", that contains "no"To solve this, we will follow these steps −n := the number of words in wchar_0 := False, char_1 := Falsefor i in range 0 to ... Read More

903 Views
Suppose we have three angles. We have to check whether it is possible to create a triangle of positive area with these angles or not.So, if the input is like a = 40 b = 120 c = 20, then the output will be True as the sum of 40 + 120 + 20 = 180.To solve this, we will follow these steps −if a, b and c are not 0 and (a + b + c) is same as 180, thenif (a + b) >= c or (b + c) >= a or (a + c) >= b, thenreturn ... Read More

527 Views
Suppose we have two lowercase strings s and t. Sometimes, when we type a vowel, the key might get long pressed, and the vowel will be repeated 1 or more times. We have to check whether it is possible that t is typed that indicates s or not.So, if the input is like s = "mine" t = "miiine", then the output will be True as vowel 'i' is repeated three times, other letters are fine.To solve this, we will follow these steps −s_len := size of st_len := size of tj := 0for i in range 0 to s_len ... Read More

440 Views
Suppose we have two strings s and t. We have to check whether s is suffix of t or not.So, if the input is like s = "ate" t = "unfortunate", then the output will be True.To solve this, we will follow these steps −s_len := size of st_len := size of tif s_len > t_len, thenreturn Falsefor i in range 0 to s_len, doif s[s_len - i - 1] is not same as t[t_len - i - 1], thenreturn Falsereturn TrueLet us see the following implementation to get better understanding −Example Live Demodef solve(s, t): s_len = len(s) ... Read More

2K+ Views
Suppose we have a string s. We have to check whether the given string is isogram or not. The isogram is a string where the occurrence of each letter is exactly one.So, if the input is like s = "education", then the output will be True because all characters in "education" occurs exactly once.To solve this, we will follow these steps −char_list := a new listfor each char in word, doif char is non numeric, thenif char is in char_list, thenreturn Falseinsert char at the end of char_listreturn TrueLet us see the following implementation to get better understanding −Example Live Demodef ... Read More

393 Views
Suppose we have a string s. We have to check whether the given string is colindrome or not. The colindrome is a concatenated string of 6 length palindromes.So, if the input is like s = "aabbaamnoonm", then the output will be True as this contains palindromes like "aabbaa" and "mnoonm", both are of length 6.To solve this, we will follow these steps −if size of s is not multiple of 6, thenreturn Falsefor i in range 0 to size of s - 1, increase by 6, doif s[from index i to i+5] is not palindrome, thenreturn Falsereturn TrueLet us see ... Read More