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
Programming Articles - Page 954 of 3363
263 Views
Suppose we are given two lists, p and q that contain some integer numbers. We have to multiply all the values of these lists and have to find out the k-th largest value from the multiplication results.So, if the input is like p = [2, 5], q = [6, 8], k = 2, then the output will be 16.The multiplication results are: 2 * 6 = 12, 2 * 8 = 16, 5 * 6 = 30, 5 * 8 = 40. The 2nd largest element at is (index starts from 0) is 16.To solve this, we will follow these ... Read More
568 Views
Suppose we are given a list that contains values in pairs of (m, c). These values represent a line, where y = mx + c. We are also given two values, l, and r. We have to find out the number of the lines that intersect with each other between the range x = l to x = h.So, if the input is like input_list = [[4, 6], [-6, 10], [8, 12]], l = 0, h = 2, then the output will be 2.If we look at the given photo, the lines 4x + 6 = 0 and -6x + ... Read More
366 Views
Suppose we are given a positive integer number. We have to spell the number in words; like if a number "56" is given as input the output will be "Fifty-Six". The range of conversion is up to a billion.So, if the input is like input = 5678, then the output will be Five Thousand Six Hundred Seventy-Eight.To solve this, we will follow these steps −Define an array ‘numbers’ that contain pairs such as − {{"Billion", 1000000000}, {"Million", 1000000}, {"Thousand", 1000}, {"Hundred", 100}, {"Ninety", 90}, {"Eighty", 80}, {"Seventy", 70}, {"Sixty", 60}, {"Fifty", 50}, {"Forty", 40}, {"Thirty", 30}, {"Twenty", 20}, {"Nineteen", 19}, ... Read More
192 Views
Suppose we are given a list of cities and a list of roads that connect each other. The list 'cities' contain the name of cities that a tour bus visits in order. In the list 'roads' the roads are listed in a (source, destination) order meaning there is a one-way road from source to destination. Now, there is a problem that some city names in the list 'cities' may be misspelled. We have to correct such misspelled city names by changing the minimum number of characters. We return the number of characters changed as output.So, if the input is like ... Read More
199 Views
Use the to_series() method to create a series from TimeDeltaIndex in Pandas.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Convert TimeDeltaIndex to Series −print("TimeDeltaIndex to series...", tdIndex.to_series()) ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the 'data' parameter tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999']) # ... Read More
236 Views
Suppose we are given a binary tree that has a root node 'root' and a linked list that has a head node 'head'. We have to find out if that linked list exists in that binary tree. If a set of nodes in the tree have links with each other in order as a linked list, and if that order is similar to that of the provided linked list, then we return 'True' or otherwise, we return 'False'.So, if the input is likeTreeLinked Listthen the output will be True.To solve this, we will follow these steps −arr := a new ... Read More
142 Views
To return TimeDeltaIndex as object ndarray of datetime.datetime objects, use the TimeDeltaIndex.to_pytimedelta() method.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Return TimeDeltaIndex as object ndarray −print("Return TimeDeltaIndex as object ndarray of datetime.datetime objects...", tdIndex.to_pytimedelta())ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the 'data' parameter as well tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min ... Read More
168 Views
To return a dataframe of the components of the TimedeltaIndex, use the TimedeltaIndex.components property.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display TimedeltaIndex −print("TimedeltaIndex...", tdIndex) Return a dataframe of the components of TimeDeltas. The components include days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds −print("The Dataframe of the components of TimeDeltas...", tdIndex.components)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have ... Read More
130 Views
To extract the number of microseconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.nanoseconds property.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display the number of nanoseconds from each element of TimeDeltaIndex −print("The number of nanoseconds from the TimeDeltaIndex object...", tdIndex.nanoseconds)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using the 'data' parameter as ... Read More
136 Views
To extract the number of microseconds for each element from TimeDeltaIndex object, use the TimedeltaIndex.microseconds property.At first, import the required libraries −import pandas as pdCreate a TimeDeltaIndex object. We have set the timedelta-like data using the 'data' parameter as well −tdIndex = pd.TimedeltaIndex(data =['10 day 5h 2 min 35s 3us 10ns', '+22:39:19.999999', '2 day 4h 03:08:02.000045', '+21:15:45.999999'])Display TimedeltaIndex −print("TimedeltaIndex...", tdIndex) Display the number of microseconds from each element of TimeDeltaIndex −print("The number of microseconds from the TimeDeltaIndex object...", tdIndex.microseconds)ExampleFollowing is the code −import pandas as pd # Create a TimeDeltaIndex object # We have set the timedelta-like data using ... Read More