Check Overlapping Prefix and Suffix in Two Lists

Niharika Aitam
Updated on 19-Oct-2023 15:05:58

400 Views

Generally, a prefix is a sequence of characters that appear at the beginning of a string or list or tuple or number, and a suffix is a sequence of characters that appear at the end of a string or number or list or tuple. For example, when we consider the list [1, 2, 3, 4, 5], the prefix is [1, 2, 3] and the suffix will be [3, 4, 5] The prefix and suffix are often used in various programming operations, such as string manipulation, text processing, and data analysis, to refer to specific parts of a sequence. Checking ... Read More

Check if a String is IPv4, IPv6 or Invalid in Python

Niharika Aitam
Updated on 19-Oct-2023 15:04:18

2K+ Views

An IP address is the short form of Internet Protocol address, which is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It serves as an identifier for the device, allowing it to send and receive data over the network. There are two versions of IP addresses commonly used: IPv4 (Internet Protocol version 4): This is the most widely used version of IP addresses. It consists of four sets of numbers separated by periods, such as "192.168.0.1". Each set can have a value between 0 and 255, representing a total ... Read More

Check If Number Is Palindrome in One Line Using Python

Niharika Aitam
Updated on 19-Oct-2023 14:59:04

714 Views

Generally, palindrome is a word, phrase, number, or other sequence of characters that reads the same forwards and backwards. In the context of a Python program, a palindrome usually refers to a string or number that remains the same when its characters or digits are reversed. For example, let’s consider the word Madam, when we read this word from left to right and right to left the word will be the same. So this is a palindrome. There are different approaches to find if the given number is palindrome in python. First let’s see the basic approach without using the ... Read More

Check Elements Around Pivot in Python

Niharika Aitam
Updated on 19-Oct-2023 14:56:54

126 Views

Generally, pivot table is the table which contains the grouped values formed by aggregating the individual elements within one or more discrete categories. In Python, the term "pivot" is often associated with sorting algorithms or operations that involve rearranging elements based on a specific value or condition. The pivot can be any element or position within the data structure, and its purpose is to divide the data into two parts: elements smaller than the pivot and elements greater than the pivot. There are different ways to check if the elements to the left and right of the pivot are smaller ... Read More

Check Date in Date Range using Python

Niharika Aitam
Updated on 19-Oct-2023 14:43:57

3K+ Views

In this article we will learn how to check if the given input date falls in the specified date range or not. There are ways to do so; some of them are explained in detail. Using the datetime module Datetime module offers classes to manipulate the dates and times. This module provides various functions and methods such as date, time, datetime, timedelta, minyear, maxyear, UTC etc. Here in this article we will use the datetime() function of the datetime module. The datetime() accepts the date, month and year as the input arguments and returns the date as output. ... Read More

Check if All Strings are Mutually Disjoint in Python

Niharika Aitam
Updated on 19-Oct-2023 14:41:20

163 Views

String is one of the data structures which hold the data enclosed in double quotes or in single quotes i.e. any data type enclosed inside the quotes considered as string. It is immutable, once we define the data we cannot change or modify. In python we have a function called str() which takes any data as the input and returns the string as output. Mutually disjoint means if no two strings are having the same elements in common. There are different ways to check if all strings are mutually disjoint. Let’s go through each one. Using nested loops Nested loop ... Read More

Change Dictionary Value in Python if It Equals k

Niharika Aitam
Updated on 19-Oct-2023 14:38:42

125 Views

Dictionary is one of the data structure available in python to store any datatype of data in the format of key and value pair. It is denoted by {} curly braces. The key in the dictionary is unique and the values in the dictionary can be repeated. The key and values pairs are separated by using the semi colon ‘:’. It is mutable i.e. once the dictionary created, we can modify the data. Dictionaries are versatile and widely used in Python for mapping and storing data where quick access to values based on keys is required. The dictionary is unordered ... Read More

Calculate Gross Pay in Python

Niharika Aitam
Updated on 19-Oct-2023 14:36:00

507 Views

Basically Gross pay is the total amount paid to an employee for the total time he/she worked, i.e. this is the full amount of salary of an employee before the taxes and deductions. The Gross pay also includes the bonuses, overtime or reimbursements from an employer on top of the salary pay. Mathematically the formula for the gross pay is as follows. Hours worked * pay per hour = gross pay per period For example, if an employee worked for 200 hours in a given period and earned Rs.300/- for an hour then the gross pay will be ... Read More

Calculate Square of a Given Number in Python

Niharika Aitam
Updated on 19-Oct-2023 14:27:05

2K+ Views

Square is the defined as the multiplication of the number by itself. The square of a number n is given as n2. Mathematically we can implement square of the number as follows. $\mathrm{n^{2}=n*n}$ In the same way we can calculate the square of a given number by using python language too. There are few approaches in python to find the square of a number, let’s see them one by one. Using exponential operator (**) The exponential operator is the operator which is used to perform the exponent arithmetic operation. It is denoted with the symbol **. Syntax The ... Read More

Calculate Date, Month, and Year from Seconds in Python

Niharika Aitam
Updated on 19-Oct-2023 14:23:07

959 Views

Generally, time is given in hours or minutes or seconds and from the given seconds, we can calculate the number of days, months and years. There are different modules and functions available in python such as datetime, time and divmod() which helps us to calculate the date month and year from seconds. Using Datatime module Datetime module offers classes to manipulate the dates and times. This module provides various functions and methods such as date, time, datetime, timedelta, minyear, maxyear, UTC etc. In the datetime method of datetime module we have the function utcfromtimestamp() which takes the seconds as ... Read More

Advertisements