Vikram Chiluka

Vikram Chiluka

216 Articles Published

Articles by Vikram Chiluka

Page 8 of 22

How to capture SIGINT in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 1K+ Views

In this article, we will learn how to capture SIGINT in Python and what has to be done after capturing it. When the signal module receives signals, it does a certain action. Besides that, it can capture the user's interruption through the keyboard using SIGINT. Modules Needed Signal Module The term "signal" refers to the process by which a program can receive information from the operating system. Additionally, the signals are sent to the program when the operating system detects specific events. By executing the following command at the terminal, the signal module can be installed − pip install signal ...

Read More

How to generate IP addresses from a CIDR address using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 5K+ Views

In this article, we will learn how to generate IP addresses from the CIDR address. Methods Used The following are the various methods to accomplish this task − Generating IPv4 Network addresses Generating IPv6 Network addresses Accessing IP addresses of the CIDR address Method 1: IPv4Network Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Use the import keyword to Import the ipaddress module. Use the ip_network() function(returns the type of network of the address ) of ipaddress module to get the IP addresses from an input CIDR address(IPv4Network) Use the ...

Read More

How to find Profit or loss using Python when CP of N items is equal to SP of M

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 645 Views

In this article, we will learn a python program to find the profit or loss when the cost price CP of N items is equal to the selling price SP of M items. Assume we have taken N, and M values which represent the cost price of N items are equal to the selling price of M items. We will now calculate the profit or loss percentage. Formula profit/loss = ( (Cost Price) - (Selling Price) ) / (Selling Price) * 100 What is the Selling Price(SP)? The price a consumer pays to purchase a product or a commodity ...

Read More

How to Determine Last Friday’s Date using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 4K+ Views

In this article, we will learn how to determine last Friday’s Date using Python. Methods Used The following are the various methods to accomplish this task − Using datetime module Using dateutil package Method 1: Using Datetime Module Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task. − Use the import keyword to import the datetime, timedelta from datetime module. Create a variable to store the list of all the days in a week(weekdays). Create a function getPreviousByDay() to return the last weekday of the input day by accepting the input day, ...

Read More

How to detect whether a Python variable is a function?

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 6K+ Views

In this article, we will learn how to detect whether a Python variable is a function. Sometimes, it is essential to figure out whether or not a Python variable is a function. When the code is a thousand lines long and you are not the creator of the code, this may appear to be of little value, and you may find yourself questioning if a variable is a function or not. Methods Used The following are the methods to check whether a python variable is a function − Using the built-in callable() function Using the isfunction() of the ...

Read More

How to create a dictionary of sets in Python?

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 3K+ Views

In this article, we will learn how to create a dictionary of sets in Python. Methods Used The following are the various methods used to accomplish this task − Using the Naive Method Using defaultdict() Method Using setdefault() Method Method 1: Using the Naive Method In this method, we create a dictionary of sets by passing sets as values to the keys. Syntax { ‘Key’: Set 1, ‘Key’:Set 2, ………….., ’Key’: Set n} Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Create a variable to store the dictionary containing ...

Read More

How to Align Text Strings using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 24-Jan-2023 36K+ Views

In this article, we will learn how to align text strings using Python. We will be using f-strings for this aligning text strings in python. Python's Text Alignment feature is helpful for printing output that is well and cleanly formatted. Sometimes the length of the data to be printed varies, making it appear untidy when printed. By specifying the alignment as left, right, or center and the space (width) to reserve for the string, the output string can be aligned using String Alignment. The text will be formatted using the f-strings. The output string's alignment is defined by the symbols ...

Read More

Find the maximum element of each row in a matrix using Python

Vikram Chiluka
Vikram Chiluka
Updated on 23-Jan-2023 3K+ Views

In this article, we will learn a python program to find the maximum element of each row in a matrix. Assume we have taken an NxN input matrix. We will now find the maximum element of each row in an input matrix using the below methods. Methos Used The following are the various methods to accomplish this task − Using Nested For Loops Using max() function Using map(), lambda functions Method 1: Using Nested For Loops Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task. − Create a function maximumRowElement() to print ...

Read More

Find the least frequent element in an array using Python

Vikram Chiluka
Vikram Chiluka
Updated on 23-Jan-2023 1K+ Views

In this article, we will learn the python program for getting the least frequent element in an array. Methods Used The following are the various methods to accomplish this task − Using sort() function(Naive Approach) Using Hashing Using Counter() Function Method 1: Using sort() function(Naive Approach) Running two loops is a simple fix. The outer loop selects each element one by one. The inner loop calculates the frequency of the selected element and compares it to the least value reached thus far. This solution's time complexity is O(n^2) Sorting is a better solution. The array is sorted first, ...

Read More

Decoding and encoding hexadecimal digitals using Python

Vikram Chiluka
Vikram Chiluka
Updated on 23-Jan-2023 5K+ Views

In this article, we will learn how to decode and encode hexadecimal digits using python. Methods Used Using binascii module Using the base64 module Method 1: Using Binascii Module There are several methods to convert between binary and different ASCII-encoded binary representations in the binascii module. Use the binascii module if all you need to do is encode or decode a raw string of hex digits. Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Use the import keyword to import the binascii module. Create a variable to store the ...

Read More
Showing 71–80 of 216 articles
« Prev 1 6 7 8 9 10 22 Next »
Advertisements