Category Archives: Technical Scripter

random header in C++ | Set 1(Generators)

This header introduces random number generation facilities. This library allows to produce random numbers using combinations of generators and distributions. Generators: Objects that generate uniformly distributed numbers. Distributions: Objects that transform sequences of numbers generated by a generator into sequences of numbers that follow a specific random variable distribution, such as uniform, Normal or Binomial.… Read More »

pprint : Data pretty printer in Python

This article is about a pretty useful built-in module in Python, pprint. The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a well-formatted and more readable way! Let us consider an example: The above code is for getting the geocode information of a place using Google Maps API in JSON format.… Read More »

Interpolation Search

Given a sorted array of n uniformly distributed values arr[], write a function to search for a particular element x in the array. Linear Search finds the element in O(n) time, Jump Search takes O(√ n) time and Binary Search take O(Log n) time. The Interpolation Search is an improvement over Binary Search for instances,… Read More »

Handling missing keys in Python dictionaries

In python, dictionaries are containers which map one key to its value with access time complexity to be O(1). But in many applications, the user doesn’t know all the keys present in the dictionaries. In such instances, if user tries to access a missing key, an error is popped indicating missing keys. Error : Traceback… Read More »

ChainMap in Python

Python also contains a container called “ChainMap” which encapsulates many dictionaries into one unit. ChainMap is member of module “collections“. Operations on ChainMap Access Operations 1. keys() :- This function is used to display all the keys of all the dictionaries in ChainMap. 2. values() :- This function is used to display values of all… Read More »