Let’s take the JSON above as an example. I need the values as a list of dictionaries in Python. This is how I did it.
We can use decorators to calculate the execution time of a function. Here the output is in milliseconds.
In Python, title() function in String method returns a new string whose first letters are capitalized. In short, title() method returns a new title cased string from a string.
Inverting a dictionary basically means keys and values are swapped i.e keys become values and values become keys.
In this tutorial we discuss the various ways of checking if a list is empty in Python. len bool equal
We can use the slicing in Python to remove the last character from a string in Python.
Source: 30 Seconds of Python
To check if a day is weekday or weekend in Python, we basically get the day number using weekday() function and see if it’s > 4 or <4. Easy!
We have already discussed Fisher-Yates algorithm in detail, which is the perfect shuffling algorithm to exist.
We can use bin() to convert a given decimal number into its binary equivalent.
Combines two lists into a dictionary, where the elements of the first one serve as the keys and the elements of the second one serve as the values.
We can use hex() to convert a given decimal number into its hexadecimal equivalent.