K Length Combinations from Given Characters in Python

Asif Rahaman
Updated on 18-Jul-2023 14:09:06

407 Views

K length combinations from given characters mean the combinations of characters that we can create with the given characters, which are exactly of length k. In this article, we will explore several methods to achieve this, like recursion, map and lambda function, itertools library, etc. While recursion and lambda functions are custom functions, the itertools provide the in-built method to generate the combinations. Using Recursion Recursion is one of the traditional programming techniques. In this technique, we try to break a large problem into smaller chunks of problems, and our motive is to solve the smaller problems to solve ... Read More

Get Function Signature in Python

Asif Rahaman
Updated on 18-Jul-2023 14:07:06

2K+ Views

Understanding function signatures in Python is essential for unraveling the inner workings of functions. The inspect module offers a range of methods to retrieve signatures, allowing you to analyze parameters, access data types, and determine default values. By exploring these techniques, you can gain valuable insights that enhance code readability, maintainability, and documentation. So, dive into the world of function signatures and unlock a deeper understanding of your Python code. Using inspect Method The inspect method provides a powerful way to retrieve the function signatures. This method enables us to access detailed information about a function's parameters, data types, default ... Read More

Get Even Indexed Elements in Tuple using Python

Asif Rahaman
Updated on 18-Jul-2023 14:05:32

450 Views

The Tuple is one of the most important data types in Python. They are exclusively used as the data structures to pass sequential data as the parameters of any method. Indexing refers to accessing the elements of the sequential data through the index. In this article, we will learn how to get an even index in elements of Tuple. Use The List And range Expression. The mutable lists sequences of data separated by ", " and enclosed by "[ ]". Python allows the conversion between the lists and the Tuples through the in-built methods. We can traverse the lists and ... Read More

Replace the Kth Word in a String Using Python

Asif Rahaman
Updated on 18-Jul-2023 14:03:32

222 Views

Strings are important data types in Python. Strings can be defined as the sequence of characters. Replacing the kth word in a String is an operation in which we want to replace the word which appears kth times in a String. In this article we will follow several methods to achieve it. We would look into the brute force method like using the loop statement, modules and libraries like re etc. Using Loop and split Method Loops are very common statements in most of the modern programming languages. We can either use the for or while loop to iterate over ... Read More

Asymmetric Encryption in Java

Way2Class
Updated on 18-Jul-2023 14:03:29

1K+ Views

Cryptography is the study and practice of different techniques to secure communication from third party. It is used for cyber security. We try to develop approaches and practices for protecting sensitive data. The sole objective of cryptography is to secure data from the attacker. Asymmetric Encryption is also referred as public/private key. Private key as goes as its name, it will be private while the public key can be distributed. Encryption is a mathematical correlation between two keys, one for encryption and the other for decryption. For example, if there are two keys “A1” and “A2”, then if key “A1” ... Read More

Get List of Running Processes Using Python

Asif Rahaman
Updated on 18-Jul-2023 14:01:34

8K+ Views

The operating system runs with hundreds of tasks/process at a single time. As a Python developer, this is important because often while dealing with programs that consume huge amounts of memory, we may want to delete some unimportant tasks. This article will explore how to get the running process list using Python. Using psutil Module The psutil module is a powerful cross−platform library for system monitoring and process management in Python. It provides a convenient and consistent API to access system−related information, such as CPU usage, memory utilization, disk usage, network statistics, etc. Being cross−platform, the same code applies to ... Read More

Get the Last N Characters of a String in Python

Asif Rahaman
Updated on 18-Jul-2023 13:59:46

5K+ Views

String Manipulation is an important task in Python. This may involve slicing the string, taking N characters, etc. These are essential tasks in Text preprocessing, like in NLP tasks, Password and data security, string comprehension and encoding, etc. Fortunately, Python offers a variety of ways to perform string manipulation. In this article, we will learn how to obtain the last N characters in a String in Python. Using for Loop The loop is a very common expression for most programming languages. This allows us to iterate over iterable objects, generate a series of values, and more. Since the String ... Read More

Get the First Element in List of Tuples in Python

Asif Rahaman
Updated on 18-Jul-2023 13:57:02

2K+ Views

Tuples are immutable data types in Python that can hold heterogeneous data types. List, on the other hand, are multiple data types that can hold heterogeneous data. In this article, we will explore various methods to retrieve the first element from a list of tuples using function−based components. We will explore several methods like loops, list comprehension, zip method, etc. Using Loop Method Loops are common statements in almost any Programming language. We can use the loop statement along with the indexing property of the iterable objects of Python to access the first elements of the iterable objects. ... Read More

Get List of Files in a Directory with Size Using Python

Asif Rahaman
Updated on 18-Jul-2023 13:54:39

2K+ Views

Directories are special kind of nodes in the computer system that contains other nested folders, files, etc. To list down the directories, we need special libraries or modules of Python like os module, glob module, etc. They also provide us the methods to access the size of the directory. The size of the directory is the space occupied by the directory in the computer ROM. In this article, we will explore how to get the list of files in a directory along with the size. Using OS Module The Python os module is a powerful tool that allows developers to ... Read More

Get List of Files in Directory Sorted by Size Using Python

Asif Rahaman
Updated on 18-Jul-2023 13:52:54

633 Views

Directory contains special nodes in computer paths that hold information about other nested paths but do not contain any information. Since they contain files and other directories, they have some size. Sorting by size means ordering the directories in terms of the space occupied by the directories in the disks. In this article, we will explore several methods, like using the os module, glob module, etc. sorted, lambda functions, etc., to perform the same. Using the OS and Operator Modules The os module Python provides a way to interact with the operating System. It offers various functions for operating ... Read More

Advertisements