Found 10436 Articles for Python

How does in operator work on list in Python?

Nikitasha Shrivastava
Updated on 16-May-2025 18:18:54

19K+ Views

The in operator in Python In Python, the in operator determines whether a given value is a constituent element of a sequence such as a string, array, list, or tuple. When used in a condition, the statement returns a Boolean result of True or False. The statement returns True if the specified value is found within the sequence. When it is not found, we get a False. In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In other programming languages, a list is equivalent to an array. Square brackets ... Read More

How does * operator work on list in Python?

Nikitasha Shrivastava
Updated on 16-May-2025 18:06:22

17K+ Views

In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In other programming languages, a list is equivalent to an array. In this article, we will show you how the * operator works on a list in python. So we will show you different examples to understand how * works on a python list in the below section − Repetition Operator(*) A repetition operator is supported by sequence datatypes (both mutable and immutable). The repetition operator * creates several copies of that object and joins them together. When used with ... Read More

How to sort the objects in a list in Python?

Vikram Chiluka
Updated on 03-Nov-2023 02:44:41

2K+ Views

In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In other programming languages, a list is equivalent to an array. Square brackets are used to denote it, and a comma (, ) is used to divide two items in the list. In this article, we will show you how to sort the objects and elements in a list using python. Below are the different methods to accomplish this task − Using sort() method Using sorted() method Assume we have taken a list containing some elements. We will ... Read More

How to append objects in a list in Python?

Nikitasha Shrivastava
Updated on 16-May-2025 18:01:11

19K+ 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. In this article, we will discuss how to add objects to a list and the different ways to add objects, such as append(), insert(), and extend() methods, in Python. Using append() method In this method, we use append() to add objects to a list. The append() method adds a new element to the end of a list that already exists. Example 1 In this example, we used the append() method ... Read More

How to find the element from a Python list with a minimum value?

Nikitasha Shrivastava
Updated on 16-Jun-2025 16:11:33

2K+ Views

A list is one of the most commonly used data structures in Python. It is mutable and has an ordered sequence of elements. In this article, we will find the element from a given list with the minimum value. We will see different examples and different ways to do this. But first, let us see how do define a list in Python. Defining a List Following is a list of integer values - lis= [12, 22, 32, 54, 15] print(lis) When you run the program, it will show this output - [12, 22, 32, 54, 15] In this article, ... Read More

How to find the element from a Python list with a maximum value?

Nikitasha Shrivastava
Updated on 16-May-2025 17:57:53

10K+ 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. Here is a simple example of a list of integer values - lis= [1, 2, 3, 4, 5] print(lis) If you execute the above program, it produces the following output [1, 2, 3, 4, 5] In this article, we will look at different ways to find the maximum of the list in Python. For the above list the maximum or largest element of the list is 5. Using ... Read More

What are character classes or character sets used in Python regular expression?

Nikitasha Shrivastava
Updated on 07-May-2025 17:54:57

2K+ Views

In this chapter, we will understand character classes, how they work. and provide simple examples and programs to explain their usage. One of the main components of regular expressions is character classes or character sets. Character classes help you to define a set of characters that will match in a string. They can be used to define a range of characters or specific characters to consider during a search. Character Classes or Character Sets A "character class, " also known as a "character set, " which helps you inform the regex engine to match only one of numerous characters. Simply ... Read More

How can import python module in IDE environment available in tutorialspoint?

Malhar Lathkar
Updated on 23-Apr-2025 17:29:16

727 Views

The Tutorialspoint coding environment normally helps you to run Python code directly in your browser, but the capacity to import external modules can be limited. Importing Python Module So you can use Python's built-in libraries and modules. To load a module into the Python IDE environment on tutorialspoint, follow the steps below - Step 1: First of all, you need to open the Tutorialspoint Python IDE. So, go to the Tutorialspoint Python IDE. ... Read More

What are the differences between “untyped” & “dynamically typed” programming languages?

Nikitasha Shrivastava
Updated on 23-Apr-2025 14:42:23

2K+ Views

When learning different programming languages, you may come across terms like untyped and dynamically typed. While they may sound similar but they have different concepts in how programming languages manage data types. In this article, we will see these concepts in simple terms with simple examples. Untyped Language Untyped programming languages do not have a strict definition of data types. This allows you to use values without providing the data type. The interpreter or execution environment will handle everything anyway it considers a match. Example Let us look at an example that uses an untyped language - # ... Read More

How to write Python regular expression to get zero or more occurrences within the pattern?

Nikitasha Shrivastava
Updated on 23-Apr-2025 10:36:49

675 Views

In this article we will be using Regular Expression to get zero or more occurrences within the pattern. Regular expressions (regex) are important features to identify patterns in text. In Python, the re module provides support for working with regex. The concept of zero or more occurrences is a key regex feature. This means that a pattern can appear somewhere between zero and an infinite number of times. Zero or More Occurrences? In regex, the * symbol denotes zero or more instances of the preceding element. For example, the pattern a* will match - ... Read More

Advertisements