Split Python Tuples into Sub-Tuples

Vikram Chiluka
Updated on 09-Nov-2022 07:48:02

11K+ Views

In this article, we will show you how to split python tuples into sub-tuples. Below are the various methods to accomplish this task − Using slicing Using enumerate() & mod operator Tuples are an immutable, unordered data type used to store collections in Python. Lists and tuples are similar in many ways, but a list has a variable length and is mutable in comparison to a tuple which has a fixed length and is immutable. Using slicing Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Create a variable to ... Read More

Represent Infinite Number in Python

Vikram Chiluka
Updated on 09-Nov-2022 07:36:38

12K+ Views

In this article, we will show you how to represent an infinite number in python. Infinity is an undefined number that can be either positive or negative. A number is used to represent infinity; the sum of two numeric values may be a numeric but distinct pattern; it may have a negative or positive value. All arithmetic operations on an infinite value, whether sum, subtraction, multiplication or any other operation, always result in an infinite number. In the field of computer science, infinity is commonly used to evaluate and optimize algorithms that do calculations on a huge scale. Infinity in ... Read More

Zip a Python Dictionary and List Together

Vikram Chiluka
Updated on 09-Nov-2022 07:04:11

12K+ Views

In this article, we will show you how to zip a python dictionary and list together. Below are the various methods to accomplish this task − Using zip() function Using append() function and items() function Using append() function and in operator. Combing dictionary and list together using zip() Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Create a variable to store the input dictionary. Create another variable to store the input list. Use the zip() function(The zip() function can be used to combine two lists/iterators) to combine the input ... Read More

Randomly Select Element from Range in Python

Vikram Chiluka
Updated on 09-Nov-2022 06:54:31

6K+ Views

In this article, we will show how to randomly select from a range in python. Below are the various methods to accomplish this task − Using random.randrange() function Using random.randint() function Using random.random() function Using random.sample() Using random.randrange() function Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Use the import keyword, to import the random module. Use the random.randrange() function(Returns a random number within the specified range) to generate a random number within the given range by passing minimum, and maximum numbers as arguments. Generate a random number from ... Read More

Find Exponential Value in Python

Vikram Chiluka
Updated on 09-Nov-2022 06:38:07

10K+ Views

In this article, we will show you how to find the exponential value in python. Below are the various methods to accomplish this task − Using exponential operator(**) Using exp() function Using exp() values with inbuilt numbers Using pow() function Using exponential operator(**) The exponential operator(**) can be used to calculate the power of a number. Since importing a module or calling a function is not necessary, this is the most convenient to use. The exponential value of an x is xth power of e, Euler's constant which is an irrational number called Euler's number and is equal ... Read More

Count Total Number of Occurrences of an Object in a Python List

Pranav Indukuri
Updated on 08-Nov-2022 12:48:44

5K+ Views

List is one of the most commonly used data structures provided by python. List is a data structure in python that is mutable and has an ordered sequence of elements. Following is a list of integer values − Example Following is a list of integer values. lis= [1, 2, 7, 5, 9, 1, 4, 8, 10, 1] print(lis) Output If you execute the above snippet, it produces the following output. [1, 2, 7, 5, 9, 1, 4, 8, 10, 1] In this article, we will discuss how to find the total count of occurrences of an object in ... Read More

Recursion Example in JavaScript to Display Numbers in Descending Order

Nikhilesh Aleti
Updated on 08-Nov-2022 08:20:18

933 Views

In this article, the given task is to display the numbers in descending order by using recursion. Let’s get an understanding of the task by looking into the input-output scenarios. Input-Output scenario Let’s look into an input-output scenario, where there is an input number and we need to print the numbers in descending order from the given number to 1. Input = 10; Output = 10 9 8 7 6 5 4 3 2 1 What is recursion? The process of calling itself is called recursion. The function which will call itself is known as a recursive function. Syntax Following ... Read More

Check Equality of Array Elements Sequence Dependent in JavaScript

Nikhilesh Aleti
Updated on 08-Nov-2022 08:08:50

338 Views

In this article, the given task is to check the equality of array elements (sequence dependent). Before we proceed into examples, let’s look at how the input-output scenario will look when we are checking the equality of array elements (sequence dependent) in JavaScript. Input-Output scenario Let’s look into the input-output scenario, where we have declared two arrays and we need to get similar elements in sequence-dependent. Array1 = [2, 5, 6, 7, 9, 0]; Array2 = [3, 5, 0, 8, 9, 4]; Output = [5, 9] In the above snippet, we can see that there are two arrays ... Read More

Embed Custom Data Attributes on All HTML Elements

Nikhilesh Aleti
Updated on 08-Nov-2022 08:02:07

588 Views

In this article, we need to embed custom data attributes on all HTML elements. we can do so, using the data-* attribute in HTML. The data-* attribute in HTML is used to custom data private to the webpage or application. This attribute adds custom values to an HTML element. The data-* attribute in HTML consists of two parts − The attribute value can be any string. The attribute name should only contain lowercase letters and must have at least one character after the prefix "data-". This data is commonly used in JavaScript to improve the user experience. Following ... Read More

Execute a Script When a User Navigates to a Page in HTML

Nikhilesh Aleti
Updated on 08-Nov-2022 07:59:00

237 Views

The task we need to perform in this article is executing a script when a user navigates to a page in HTML. We can do the above task (executing a script when a user navigates to a page in HTML) by using "onpageshow Event". Before we jump into the examples let’s look into the definition and usage of onpageshow event in HTML. HTML onpageshow event The onpageshow event in HTML occurs when a user navigates to a webpage. This event occurs every time the page is loaded. Syntax Following is the syntax of onpageshow event in HTML − ... Read More

Advertisements