Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 36 of 2547
Python program to determine if the given IP Address is Public or Private using ipaddress module
In computer networking, IP addresses are used to uniquely identify devices connected to a network. IP addresses can be classified as either public or private. Public IP addresses are assigned to devices that are directly connected to the Internet. They are globally routable and can be accessed from anywhere on the Internet. Private IP addresses, on the other hand, are used within private networks, such as local area networks (LANs) or home networks. These IP addresses are not directly accessible from the Internet. Private IP addresses are defined by certain reserved address ranges specified by the Internet Engineering ...
Read MorePython Program to create an OTP by squaring and concatenating the odd digits of a number
The task is to create a One-Time Password (OTP) by squaring and concatenating the odd digits of a given number. This technique extracts odd digits from a number, squares each one, and joins them together to form a secure OTP. Input Output Scenarios Following are the input-output scenarios for creating an OTP by squaring and concatenating the odd digits of a number ? # Example 1 number = 123456789 print(f"Input number: {number}") # Extract odd digits: 1, 3, 5, 7, 9 # Square them: 1, 9, 25, 49, 81 # Concatenate: "19254981" otp = "19254981" ...
Read MorePython program to create a list centered on zero
Creating a list centered on zero involves generating a sequence of numbers where zero is positioned in the middle of the list. While the size of the list can be customized, it is often preferred to use an odd number to ensure symmetrical distribution of elements around zero. In this article, we will discuss different approaches to creating a list centered on zero using Python programming. Approach We can follow the below steps to create a centered list: Determine the desired size of the list. Let's call this value n. If n is an odd ...
Read MorePython program to convert meters in yards and vice versa
A meter is the fundamental unit of length in the International System of Units (SI) and is used worldwide. It is defined as the length of the path traveled by light in a vacuum during a time interval of 1/299, 792, 458 of a second. Meters are commonly used in scientific, engineering, and everyday contexts. The yard, on the other hand, is a unit of length commonly used in both the British imperial and US customary systems of measurement. It is an English unit defined as 3 feet or 36 inches. It is defined as exactly 0.9144 meters. Yards ...
Read MorePython Program to Count Vowels, Lines, and Characters in Text File
When working with text processing and analysis tasks, it is frequently required to count the vowels, lines, and characters in a text file. The goal is to determine the total counts of vowels, lines, and characters present in the file. Python provides various methods and techniques that can be used to accomplish these counting tasks effectively and efficiently. In this article, we will discuss different approaches for counting vowels, lines, and characters in a text file using Python programming. Approach By following the below steps, we can effectively count the vowels, lines, and characters in a text ...
Read MorePython program to count the number of blank spaces in a text file
Blank spaces in a text file refer to the empty spaces or gaps between words, sentences, or characters. These spaces are typically represented by the space character (' ') or other whitespace characters, including tab ('\t'), newline (''), carriage return ('\r'), form feed ('\f'), and vertical tab ('\v'). These characters, as per the Unicode standard, represent empty space or formatting elements in the text. When counting the number of blank spaces in a text file, we are essentially looking for these whitespace characters to determine the frequency or distribution of spaces within the text. This information can be useful ...
Read MorePython program to convert float to exponential
Float to exponential conversion transforms a decimal number into scientific notation (e.g., 1.23e+05). This format is useful for expressing very large or small numbers concisely in scientific calculations. Python provides three main approaches for converting floats to exponential notation: format() function, f-string formatting, and str.format() method. All use the 'e' format specifier to display numbers in scientific notation. Input Output Examples Here are common scenarios for float to exponential conversion ? Input: 1203100323.8932872122 Output: 1.203100e+09 Input: 0.0000123456789 Output: 1.23456789e-05 Input: 9876543.21 Output: 9.87654321e+06 The exponential notation shows the coefficient (significant digits) ...
Read MorePython Program To Convert dictionary values to Strings
A dictionary in Python is an unordered collection of key-value pairs. It is a data structure that allows you to store and retrieve values based on a unique key associated with each value. Keys in a dictionary must be immutable (strings, numbers, or tuples), while values can be of any data type and can be mutable. When we want to convert dictionary values to strings, we need to iterate over the dictionary and convert each value to a string using the str() function. Input Output Scenarios See the following input-output scenarios to understand the concept of converting ...
Read MorePython Program to convert Dictionary to List by Repeating keys corresponding value times
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 following input-output scenarios to understand the concept of converting a dictionary to a list by repeating keys corresponding to the number present in the values ? Input dictionary: {'a': 3, 'b': 2, 'c': 1} Output list: ['a', 'a', 'a', 'b', 'b', 'c'] In the ...
Read MorePython program to convert Dict of list to CSV
A dictionary of lists is a common data structure where each key maps to a list of values. Converting this structure to CSV format is useful for data analysis and sharing tabular data. Here's an example of a dictionary of lists ? data = { 'numbers': [1, 2, 3, 4, 5, 6], 'states': ['UP', 'Tamil Nadu', 'Telangana', 'Gujarat', 'UP', 'Tamil Nadu'], 'cities': ['Agra', 'Chennai', 'Hyderabad', 'Surat', 'Lucknow', 'Coimbatore'] } print(data) {'numbers': [1, 2, 3, 4, 5, 6], 'states': ['UP', 'Tamil Nadu', 'Telangana', ...
Read More