- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 10783 Articles for Python
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
3K+ Views
Suppose we have a string that is representing a 12-hour clock time with suffix am or pm, and an integer n is also given, we will add n minutes to the time and return the new time in the same format.So, if the input is like s = "8:20pm" and n = 150, then the output will be 10:50pmTo solve this, we will follow these steps −h, m := take the hour and minute part from sh := h mod 12if the time s is in 'pm', thenh := h + 12t := h * 60 + m + nh ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
1K+ Views
Suppose we have a string s that is representing a phrase, we have to find its acronym. The acronyms should be capitalized and should not include the word "and".So, if the input is like "Indian Space Research Organisation", then the output will be ISROTo solve this, we will follow these steps −tokens:= each word of s as an arraystring:= blank stringfor each word in tokens, doif word is not "and", thenstring := string concatenate first letter of wordreturn convert string into uppercase stringLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, s): ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
184 Views
Suppose we have a mobile phone which is in "eco mode". This mode activates once your battery level reaches 20 percent. In this eco mode the battery drains two times slower than in normal mode. Now when we leave our home, we have 100% of battery. Then t minutes after we have p percent of battery left. We have to find how many minutes we have until our phone will turn off.So, if the input is like t = 75 and p = 25, then the output will be 45To solve this, we will follow these steps −if p < ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
242 Views
Suppose we have a positive number n, we have to find that we can make n by summing up some non-negative multiple of 3 and some non-negative multiple of 7 or not.So, if the input is like 13, then the output will be True, as 13 can be written as 1*7+2*3 = 13To solve this, we will follow these steps −for i in range 0 to n+1, increase by 7, doif n-i is divisible by 3, thenreturn Truereturn FalseLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, n): for i ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
669 Views
Suppose we have a number n, we have to construct a list with each number from 1 to n, except when it is multiple of 3 or has a 3, 6, or 9 in the number, it should be the string "no-fill".So, if the input is like 20, then the output will be ['1', '2', 'clap', '4', '5', 'clap', '7', '8', 'clap', '10', '11', 'clap', 'clap', '14', 'clap', 'clap', '17', 'clap', 'clap', '20']To solve this, we will follow these steps −string := "no-fill"ls:= make a list of numbers as string from 1 to nfor i in range 0 to size ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
3K+ Views
Suppose we have a string s. Here s is representing a 12-hour clock time with suffixes am or pm, we have to find its 24-hour equivalent.So, if the input is like "08:40pm", then the output will be "20:40"To solve this, we will follow these steps −hour := (convert the substring of s [from index 0 to 2] as integer) mod 12minutes := convert the substring of s [from index 3 to 5] as integerif s[5] is same as 'p', thenhour := hour + 12return the result as hour:minutesLet us see the following implementation to get better understanding −Example Live Democlass Solution: ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
292 Views
Suppose we have an integer n, where only 1, 2, and 3 these digits are present. We can flip one digit to a 3. Then find the maximum number we can make.So, if the input is like 11332, then the output will be 31332To solve this, we will follow these steps −li := a list by digits of nfor x in range 0 to size of li - 1, doif li[x] is not '3', thenli[x] := '3'return the number by merging digits from lireturn nLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
70 Views
Suppose we have an array of numbers; we have to find a number B which is the divisor of all except for exactly one element in the given array. We have to keep in mind that the GCD of all the elements is not 1.So, if the input is like {8, 16, 4, 24}, then the output will be 8 as this is the divisor of all except 4.To solve this, we will follow these steps −n := size of arrayif n is same as 1, thenreturn(array[0] + 1)prefix := an array of size n, and fill with 0suffix := ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
204 Views
Suppose we have two strings S and T, we have to check whether a string of the same length which is lexicographically bigger than S and smaller than T. We have to return -1 if no such string is available. We have to keep in mind that S = S1S2… Sn is termed to be lexicographically less than T = T1T2… Tn, provided there exists an i, so that S1= T1, S2= T2, … Si – 1= Ti – 1, Si < Ti.So, if the input is like S = "bbb" and T = "ddd", then the output will be ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
77 Views
Suppose we have an array A, we have to find a number X such that (A[0] XOR X) + (A[1] XOR X) + … + A[n – 1] XOR X is as minimum as possible.So, if the input is like [3, 4, 5, 6, 7], then the output will be X = 7 , Sum = 10To solve this, we will follow these steps −Define a function search_res() . This will take arr, nelement := arr[0]for i in range 0 to size of arr, doif arr[i] > element, thenelement := arr[i]p := integer of (log of element base 2) + ... Read More