Gireesha Devara has Published 249 Articles

Python Program to convert Dictionary to List by Repeating keys corresponding value times

Gireesha Devara

Gireesha Devara

Updated on 29-Aug-2023 14:10:32

60 Views

In Python, dictionaries are key-value pairs where each key is associated with a corresponding value. When we want to convert a dictionary to a list by repeating keys, we need to iterate over each key-value pair and repeat the key based on its corresponding value. Input Output Scenarios See the ... Read More

Python program to convert Dict of list to CSV

Gireesha Devara

Gireesha Devara

Updated on 29-Aug-2023 14:07:37

376 Views

In a dictionary, keys must be unique and immutable, while values can be of any type and can have a list of values. In the case of a dictionary of lists, each key points to a list that can contain multiple elements.  Here's an example of a dictionary of lists ... Read More

Python program to Count Uppercase, Lowercase, special character and numeric values using Regex

Gireesha Devara

Gireesha Devara

Updated on 29-Aug-2023 14:05:18

326 Views

Regular expressions, commonly known as re or Regex is a powerful tool for manipulating and searching for patterns in text. In Python, regular expressions are implemented using the re-module. A regular expression is a sequence of characters that define a search pattern. The pattern is used to match and manipulate ... Read More

How to check the data type in pandas DataFrame?

Gireesha Devara

Gireesha Devara

Updated on 29-Aug-2023 07:20:28

190K+ Views

To check the data type in pandas DataFrame we can use the "dtype" attribute. The attribute returns a series with the data type of each column.And the column names of the DataFrame are represented as the index of the resultant series object and the corresponding data types are returned as ... Read More

How to know if an object has an attribute in Python?

Gireesha Devara

Gireesha Devara

Updated on 29-Aug-2023 03:41:46

20K+ Views

Python is an object-oriented programming language, here attributes are known as properties of an object. By using different methods, we can check if an object has an attribute or not. To check if an object contains a particular attribute then we can use hasattr() method and getattr() method. Or if ... Read More

How to wrap python object in C/C++?

Gireesha Devara

Gireesha Devara

Updated on 24-Aug-2023 16:01:06

199 Views

To wrap existing C or C++ functionality in Python, there are number of options available, which are: Manual wrapping using PyMethodDef and Py_InitModule, SWIG, Pyrex, ctypes, SIP, Boost.Python, and pybind1. Using the SWIG Module Let’s take a C function and then tune it to python using SWIG. The SWIG stands ... Read More

How we can update a Python tuple element value?

Gireesha Devara

Gireesha Devara

Updated on 24-Aug-2023 15:52:50

1K+ Views

Python tuple is an immutable object, which means once tuple is created you cannot change, update, add, or remove its values. If we try to update any of its elements, then it will throw the TypeError. In this article, we will use three different ways like list conversion, slicing, packing, ... Read More

How to create a dictionary with list comprehension in Python?

Gireesha Devara

Gireesha Devara

Updated on 24-Aug-2023 14:30:19

355 Views

By using the dict() method in python we can create a python dictionary with the list comprehension. The syntax of dict() method is given below. Following is the syntax for this dict(**kwarg) Keyword arguments. We can pass one or more keyword arguments. If no keyword argument is passed then ... Read More

How to flatten a shallow list in Python?

Gireesha Devara

Gireesha Devara

Updated on 24-Aug-2023 14:26:23

828 Views

Flattening a shallow list means converting a nested list into a simple single dimensional list. In other words, converting a multidimensional list into a one-dimensional list. The process of flattening can be performed by using different techniques like nested for loops, list comprehensions, list concatenation, and by using built-in functions. ... Read More

How to clone or copy a list in Python?

Gireesha Devara

Gireesha Devara

Updated on 24-Aug-2023 13:32:04

528 Views

The list in Python is a sequence data type which is used to store various types of data. A list is created by placing each data element inside square brackets [] and these are separated by commas. In Python, assignment operator doesn’t create a new object, rather it gives another ... Read More

Advertisements