HackerRank Collections.OrderedDict() solution in python | python question solution

collections.OrderedDictAn OrderedDict is a dictionary that remembers the order of the keys that were inserted first. If a new entry overwrites an existing entry, the original insertion position is left unchanged.ExampleCode>>> from…

Continue ReadingHackerRank Collections.OrderedDict() solution in python | python question solution

HackerRank No Idea! problem solution in Python | python question solution

There is an array of  integers. There are also  disjoint sets,  and , each containing  integers. You like all the integers in set  and dislike all the integers in set . Your initial happiness is . For each  integer…

Continue ReadingHackerRank No Idea! problem solution in Python | python question solution

HackerRank Find Angle MBC solution in python | python question solution

  is a right triangle,  at .Therefore, .Point  is the midpoint of hypotenuse .You are given the lengths  and .Your task is to find  (angle , as shown in the figure) in degrees.Input FormatThe first line contains the length of…

Continue ReadingHackerRank Find Angle MBC solution in python | python question solution

HackerRank Collections.namedtuple() solution in python | python question solution

 collections.namedtuple()Basically, namedtuples are easy to create, lightweight object types.They turn tuples into convenient containers for simple tasks.With namedtuples, you don’t have to use integer indices for accessing members of a tuple.ExampleCode 01>>> from…

Continue ReadingHackerRank Collections.namedtuple() solution in python | python question solution

HackerRank Exceptions problem solution in python | python problem solution

ExceptionsErrors detected during execution are called exceptions.Examples:ZeroDivisionErrorThis error is raised when the second argument of a division or modulo operation is zero.>>> a = '1'>>> b = '0'>>> print int(a) /…

Continue ReadingHackerRank Exceptions problem solution in python | python problem solution

HackerRank DefaultDict Tutorial solution in Python | python problem solution

 The defaultdict tool is a container in the collections class of Python. It's similar to the usual dictionary (dict) container, but the only difference is that a defaultdict will have a default value if…

Continue ReadingHackerRank DefaultDict Tutorial solution in Python | python problem solution

HackerRank Introduction to Sets solution in python | python question solution

A set is an unordered collection of elements without duplicate entries.When printed, iterated or converted into a sequence, its elements will appear in an arbitrary order.Example>>> print set()set([])>>> print set('HackerRank')set(['a', 'c', 'e',…

Continue ReadingHackerRank Introduction to Sets solution in python | python question solution

HackerRank Polar Coordinates solution in python | python example solution

Polar coordinates are an alternative way of representing Cartesian coordinates or Complex Numbers.A complex number  is completely determined by its real part  and imaginary part .Here,  is the imaginary unit.A polar coordinate () is completely determined by modulus  and…

Continue ReadingHackerRank Polar Coordinates solution in python | python example solution

HackerRank itertools.permutations() solution in Python | python problem solution

itertools.permutations(iterable[, r])This tool returns successive  length permutations of elements in an iterable.If  is not specified or is None, then  defaults to the length of the iterable, and all possible full length permutations are generated.Permutations…

Continue ReadingHackerRank itertools.permutations() solution in Python | python problem solution