Python Sequence Tutorial

Python Sequence Tutorial

In this tutorial, we will learn about Python Sequence. In python programming, Sequence are of many types like, list [ ], tuples ( ), Strings, sets { }, Dictionaries{key:value} and many more. Operations in sequences are Length, Select, Slicing, Count, Indexing, Membership, Concatenation, Min_value, Max_value, Sum, Repetition, etc.

Python Sequence

The python sequence is like containers with items that are accessible by indexing or slicing. The built-in len function takes any container as an argument and returns the number of items in the container.

Python Sequence are:

  • List [ ]
  • Tuples ( )
  • Strings
  • Sets { }
  • Dictionaries {key : value}
Python Sequence

List :

The list contains different data types which can be written as a list of comma-separated values between square brackets. Important things about the list are that items in a list need not be of the same type. The Operation which can be implemented in the list are append, Insert, Extend, Index, Remove, Sort, Reverse.

For example: List1 = [‘Apple’, 5, 3.2, ‘India’ ]

Tuples :

A tuple is a sequence of immutable Python objects. Tuples are just like lists. The difference is, tuples cannot be changed unlike lists and tuples use parentheses. The Operation which can be implemented in tuples are Index, Slicing, Concatenation, Repetition, Count.

For Example: Tuples1 = (‘ram’, ‘john’, ‘tom’)

Strings :

In Python Sequence, String can be created simply by enclosing characters in quotes. In python, single quotes and double quotes treat as same. The Operation which can be implemented in Strings are Slicing, Updating, Concatenation, Repetition, Membership, Reverse.

For Example: Strings1 = ‘Salman is watching movie’


In python Sequence, A set contains an unordered collection of unique and immutable objects. In sets the data type is as the name implies, a python implementation of the sets as they are known from mathematics. The Operation which can be implemented in sets are Slicing, Difference, Add element, Discard, Clear, Remove, Copy, Intersection.

For Example: set1 = {‘apple’, ‘ball’, ‘cat’} & set2 = {‘UK’, ‘Apple’, ‘US’}

Intersection of set1 and set2: {‘Apple’}


In python sequence, Dictionaries is an unordered collection of key-value pairs. In python programming, It is generally used when we have a huge amount of data. The Operation which can be implemented in Dictionaries are length, del d[k], Membership.

For Example: Dict1 = {1 : ‘john’, 2 : ‘tom’, 3 : ‘Mica’}

Operations in Python Sequence

  • Append: – It is used for inserting the element in the sequence.
  • Length: – It is used to find the length of the sequence.
  • Select: – It is used to select the item from the sequence by indexing.
  • Slicing: – It is used to slice the sequence.
  • Count: – It is used to count the elements of the sequence.
  • Indexing: – It is used to find the indexing number of the element in the sequence.
  • Membership: – It is used to check the element is present in the sequence or not.
  • Concatenation: – It is used to add two sequences to make it a single sequence.
  • Min_value: – It is used to find the min_value in the sequence.
  • Max_value: – It is used to find the max_value in the sequence.
  • Sum: – It is used to add the element into the sequence.
  • Repetition: – It is used to concatenate the element in repetition.
Operations in python sequence

Video Tutorial For Python Sequence

FAQ for Python Sequence

What is Python Sequence?

In python programming, Python Sequence is just like a container with elements which can be accessible by indexing or slicing. Sets, Tuples, Dictionaries, list, string are main python sequence.

What operations are used in python sequence?

In python programming, The operation which is used in python are length, select, slicing, count, indexing, membership, concatenation, min_value, max_value, sum, repetition, etc.

Learn More Python Programming Language

5 thoughts on “Python Sequence Tutorial”

  1. Heya i am for the first time here. I came across this board
    and I find It truly useful & it helped me out much.

    I hope to give something back and help others like
    you helped me.


Leave a Comment

Share via
Copy link
Powered by Social Snap