Sherlock is given square tiles, initially both of whose sides have length placed in an plane; so that the bottom left corner of each square coincides with the the origin and their sides are parallel to the axes. At…
Objective Today, we're learning about a new data type: sets. Concept If the inputs are given on one line separated by a space character, use split() to get the separate values in the form of a list: If the list values…
.remove(x) This operation removes element from the set. If element does not exist, it raises a KeyError. The .remove(x) operation returns None. Example>>> s = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> s.remove(5) >>> print s…
any() This expression returns True if any element of the iterable is true. If the iterable is empty, it will return False. Code all() This expression returns True if all of the elements of the iterable are true. If the…
The itertools module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an iterator algebra making it possible to construct specialized tools…
In this challenge, the task is to debug the existing code to successfully execute all provided test files. Consider that vowels in the alphabet are a, e, i, o, u and y. Function score_words takes a list of lowercase…
You are given a string S. S contains alphanumeric characters only. Your task is to sort the string in the following manner: All sorted lowercase letters are ahead of uppercase letters. All sorted uppercase letters are…
You are given a spreadsheet that contains a list of athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the th attribute and print the final resulting table…
The re.sub() tool (sub stands for substitution) evaluates a pattern and, for each valid match, it calls a method (or lambda).The method is called for all matches and can be used to modify strings in different ways.
You and Fredrick are good friends. Yesterday, Fredrick received credit cards from ABCD Bank. He wants to verify whether his credit card numbers are valid or not. You happen to be great at regex so he is asking for your…
Given a list of rational numbers,find their product. Concept The reduce() function applies a function of two arguments cumulatively on a list of objects in succession from left to right to reduce it to one value. Say…
A valid postal code have to fullfil both below requirements:
must be a number in the range from to inclusive.
must not contain more than one alternating repetitive digit pair.
You are given a function . You are also given lists. The list consists of elements.
You have to pick one element from each list so that the value from the equation below is maximized:
You are given a positive integer N. Your task is to print a palindromic triangle of size N. For example, a palindromic triangle of size 5 is: You can't take more than two lines. The first line (a for-statement) is…
You are given an integer followed by email addresses. Your task is to print a list containing only valid email addresses in lexicographical order. Valid email addresses must follow these rules: It must have the…
When users post an update on social media,such as a URL, image, status update etc., other users in their network are able to view this new post on their news feed. Users can also see exactly when the post was published, i.e, how many hours, minutes or seconds ago.
If we want to add a single element to an existing set, we can use the .add() operation. It adds the element to the set and returns 'None'. Example Task Apply your knowledge of the .add() operation to help your friend…