Found 27104 Articles for Server Side Programming

How to convert a list into a tuple in Python?

Pranav Indukuri
Updated on 25-Oct-2023 14:30:50

23K+ Views

List and Tuple in Python are the class of data structure. The list is dynamic, whereas the tuple has static characteristics. We will understand list and tuple individually first and then understand how to convert a list into a tuple. List Lists are a popular and widely used data structures provided by Python. A List is a data structure in python that is mutable and has an ordered sequence of elements. Following is a list of integer values − lis= [10, 20, 30, 40, 50] print(lis) If you execute the above snippet, it produces the following output − [10, ... Read More

How to index and slice a tuple in Python?

Pranav Indukuri
Updated on 29-Aug-2023 03:45:22

27K+ Views

A tuple is an ordered and immutable collection of Python objects separated by commas. Like lists, tuples are sequences. Tuples differ from lists in that they can't be modified, whereas lists can, and they use parentheses instead of square brackets. tup=('tutorials', 'point', 2022, True) print(tup) If you execute the above snippet, produces the following output − ('tutorials', 'point', 2022, True) In this article, we will discuss how to index and slice tuples in python. Indexing Tuples In Python, every tuple with elements has a position or index. Each element of the tuple can be accessed or manipulated by ... Read More

How does the del operator work on a tuple in Python?

Pranav Indukuri
Updated on 02-Nov-2023 21:33:13

5K+ Views

A tuple is an ordered and immutable collection of Python objects separated by commas. Like lists, tuples are sequences. Tuples differ from lists in that they can't be modified, whereas lists can, and they use parentheses instead of square brackets. tup=('tutorials', 'point', 2022, True) print(tup) If you execute the above snippet, produces the following output − ('tutorials', 'point', 2022, True) In this article, we discuss about the use of the del operator on a tuple. The del operator The del keyword is mostly used in Python to delete objects. Because everything in Python is an object, the del ... Read More

How does the repetition operator work on a tuple in Python?

Pranav Indukuri
Updated on 03-Nov-2023 00:39:32

4K+ Views

A tuple is an ordered and immutable collection of Python objects separated by commas. Like lists, tuples are sequences. Tuples and lists differ in that tuples cannot be altered, although lists may, and tuples use parentheses whereas lists use square brackets. tup=('tutorials', 'point', 2022, True) print(tup) If you execute the above snippet, produces the following output − ('tutorials', 'point', 2022, True) In this article, we discuss different ways to repeat a tuple in python. Repetition operation on tuples. To repeat the same tuple for a particular number of times, then the following ways can be used. Using ... Read More

How does concatenation operator work on tuple in Python?

Rajendra Dharmkar
Updated on 05-Sep-2022 09:17:09

1K+ Views

A tuple is a collection of python objects that are separated by commas which are ordered and immutable. Tuples are sequences, just like lists. The differences between tuples and lists are, that tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets. tup=('tutorials', 'point', 2022, True) print(tup) If you execute the above snippet, produces the following output − ('tutorials', 'point', 2022, True) In this article, we will look at how to concatenate operator works on tuples in python. Concatenate operation on tuples Concatenation of tuples in python means joining two or more tuples ... Read More

How does the 'in' operator work on a tuple in Python?

Pranav Indukuri
Updated on 05-Sep-2022 09:09:39

1K+ Views

In this article, we discuss about the ‘in’ operator and how it works on tuples in python. Before moving on, we will discuss about tuples first. Tuple Tuples are a data type that belongs to the sequence data type category. They're similar to lists in Python, but they have the property of being immutable. We can't change the elements of a tuple, but we can execute a variety of actions on them such as count, index, type, etc. Tuples are created in Python by placing a sequence of values separated by a 'comma', with or without the use of parenthesis ... Read More

Why do you think tuple is an immutable in Python?

Pranav Indukuri
Updated on 05-Sep-2022 09:16:38

4K+ Views

In this article, we will discuss why tuples in python are immutable. Before moving on, we will understand tuples in detail. Tuple Tuples are a data type that belongs to the sequence data type category. They're similar to lists in Python, but they have the property of being immutable. We can't change the elements of a tuple, but we can execute a variety of actions on them such as count, index, type, etc. Tuples are created in Python by placing a sequence of values separated by a 'comma', with or without the use of parenthesis for data grouping. Tuples can ... Read More

What is the difference between a python tuple and a dictionary?

Pranav Indukuri
Updated on 03-Nov-2023 00:45:49

14K+ Views

In this article, we will discuss the difference between a python tuple and dictionary. Tuple Tuples are a data type that belongs to the sequence data type category. They're similar to lists in Python, but they have the property of being immutable. We can't change the elements of a tuple, but we can execute a variety of actions on them such as count, index, type, etc. Tuples are created in Python by placing a sequence of values separated by a 'comma', with or without the use of parenthesis for data grouping. Tuples can have any number of elements and any ... Read More

What is the difference between a python list and an array?

Pranav Indukuri
Updated on 03-Nov-2023 00:50:13

3K+ Views

In Python, both array and the list are used to store the data as a data structure. In this article, we discuss the difference between a list and an array. List Lists are one of the four most commonly used data structures provided by Python. A list is a data structure in python that is mutable and has an ordered sequence of elements. Lists also support negative indexing. Following is a list of integer values − lis= [1, 2, 3, 4, 5] print(lis) Output If you execute the above snippet, produces the following output − [1, 2, 3, 4, ... Read More

How to declare a variable in Python without assigning a value to it?

Pranav Indukuri
Updated on 03-Nov-2023 02:00:45

7K+ Views

Python variable is a symbolic name for an object that serves as a reference or pointer. You can refer to an object by its name once it has been assigned to a variable. The data, on the other hand, is still contained within the object. For example, a is assigned the value 100. ‘a’ is a variable. a = 100 This assignment creates an integer object with the value 100 and assigns the variable a to point to that object. In the above example, we have assigned a value(100) to the variable, but in this article, we will see ... Read More

Advertisements