Python Data Structure


Data Structure:

The data structure is a way to store and organize data in an efficient way. The data structure is a set of algorithms that we can use in any programming language to structure the data in the memory.

Data Structure in Python: 

Python provides a variety of useful built-in data structures, such as lists, sets, and dictionaries. For the most part, the use of these structures is straightforward.

  1. Tuple: Tuple is used to store multiple items in a single variable. It is a collection and unchangeable. Tuples are written within round brackets.  

Example: Tuple1 = ("apple""banana")
         print(Tuple1)

  1.  List: A list is used to storing multiple items in a single variable. A list can also have another list of items. This called a nested list. We can use the index operator [ ] to access an item in a list.   Python provides multiple methods for lists.                                                                                           Example:  l1 = [ ]     # empty list                                                                                                                                  l1 = [2,3,'Hi',4.3]    # list with mixed data types.

Problem Statement:

You have an N-element tuple or a sequence that you would like to unpack into a collection of N variables.

Answer: 






Comments

Popular posts from this blog

How to convert PDF file into audio file?

How to perform operations on emails and folders using imap_tools?

Pillow Libary in Python.