Let’s use this JSON as an example. I would like to find out if rank key is already in this JSON. To check if a key exists in a JSON, […]
Let’s take the list of dictionaries above as an example. I’d like to sort this list based on the scores value. To do this we can use the sorted() function […]
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.
To get the length of a string in bytes, first convert the string to Blob and use the size property of blob object to get its length in bytes.
Inverting a dictionary basically means keys and values are swapped i.e keys become values and values become keys.
We can use the slicing in Python to remove the last character from a string in Python.
Source: 30 Seconds of Python
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.
repr() returns a string that holds a printable representation of an object Examples Source: GitHub
Example Example 2