Nizamuddin Siddiqui has Published 2303 Articles

Python - Ways to invert mapping of dictionary

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 14:22:50

385 Views

Dictionary is a collection which is unordered, changeable and indexed. In Python, dictionaries are written with curly brackets, and they have keys and values. It is widely used in day to day programming, web development, and machine learning.Example Live Demo# using dict comprehension # initialising dictionary ini_dict = {101: "vishesh", 201 ... Read More

Python - Ways to format elements of given list

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 14:15:44

3K+ Views

A list is a collection which is ordered and changeable. In Python lists are written with square brackets. You access the list items by referring to the index number. Negative indexing means beginning from the end,  -1 refers to the last item. You can specify a range of indexes by specifying ... Read More

Python - Ways to flatten a 2D list

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 14:04:15

1K+ Views

A list is a collection which is ordered and changeable. In Python lists are written with square brackets. You access the list items by referring to the index number. Negative indexing means beginning from the end,  -1 refers to the last item. You can specify a range of indexes by specifying ... Read More

Python - Ways to find indices of value in list

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 14:00:31

218 Views

Usually, we require to find the index, in which the particular value is located. There are many method to achieve that, using index() etc. But sometimes require to find all the indices of a particular value in case it has multiple occurrences in list.Example Live Demo# using filter() # initializing list test_list = ... Read More

Python - Ways to create triplets from given list

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 13:58:29

406 Views

A list is a collection which is ordered and changeable. In Python lists are written with square brackets. You access the list items by referring to the index number. Negative indexing means beginning from the end,  -1 refers to the last item. You can specify a range of indexes by specifying ... Read More

Python - Ways to convert array of strings to array of floats

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 13:45:32

765 Views

String literals in python are surrounded by either single quotation marks, or double quotation marks. Assigning a string to a variable is done with the variable name followed by an equal sign and the string. You can assign a multiline string to a variable by using three quotes.Example Live Demo# array ... Read More

Python - Visualizing image in different color spaces

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 13:43:25

272 Views

OpenCV-Python is a library of Python bindings designed to solve computer vision problems. OpenCV-Python makes use of Numpy, which is a highly optimized library for numerical operations with a MATLAB-style syntax. All the OpenCV array structures are converted to and from Numpy arrays.Example# read image as RGB # Importing cv2 and matplotlib module import cv2 import ... Read More

Python - Using variable outside and inside the class and method

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 13:21:56

3K+ Views

Python is an object-oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects.The variables that are defined outside the class can be accessed by any class or any methods in the class ... Read More

Python - Using 2D arrays/lists the right way

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 13:17:51

215 Views

Python provides many ways to create 2-dimensional lists/arrays. However, one must know the differences between these ways because they can create complications in code that can be very difficult to trace out.Example Live Demorows, cols = (5, 5) arr = [[0]*cols]*rows #lets change the first element of the 1st row to ... Read More

Python - Prefix sum list

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Aug-2020 13:16:17

937 Views

A list is a collection which is ordered and changeable. In Python lists are written with square brackets. You access the list items by referring to the index number. Negative indexing means beginning from the end,  -1 refers to the last item. You can specify a range of indexes by specifying ... Read More

Advertisements