Python Data structure by Shweta Dhraik

This is my second week to learn python as my previous blog i write about strength of python and this this week i have learn about python data structure.Data structure are a way to organizing and storing data so that the data can be accessed easily and work efficiently. It define the relationship between the data, and the operations that can be performed on the data.So here are some types of data structure in python.

  • String

  • List

  • Tuple

  • Dictionaries

  • Sets

String:String is a set of character.Python does not support a character type, these are treated as a string of length one.and we can create strings by enclosing a sequence of characters within a pair of single or double quotes. For example: 'Python', "Structure"string is immutable.Here + operation is use to concatenate the string.For e.g. 'abc'+'def' output is 'abcdef' and * operation is use repeat a string certain number of time.e.g 'abc'*3 output is abcabcabc.we can also slice string which means we can select parts of string.x='Python' print(s[0:3]) output:Pyt

List:List is most widely used data structure.It grow and shrink size as needed and it is sequence type and sort able. Lists store heterogeneous items. These are mutable, which means that we can change their content without changing their identity. WE can recognize lists by their square brackets [ ] that hold elements, separated by a comma .list=[123,apple,]

Tuple:Tuples are sequence data type. The difference between tuples and list is that tuples are immutable, which means once defined you cannot delete, add or edit any values inside it.A Tuple is defined in the same way as a list but the difference is that tuple whole set of elements are enclosed in parentheses instead of square brackets. x=(Python,abc)

Dictionaries:Dictionaries are made up of key-value pairs. key is used to identify the item and the value holds as the name , the value of the item.Dictionary is written as a series of key: value pairs, separated by commas,enclosed in curly braces{}. x={1:"java",2:"Python",3:"c"}

Sets:Sets are a collection of unique objects. These are useful to create lists and it can only hold unique values in the data set. Data is not in sequence but it is mutable, it is very helpful when going through a huge data set.It is a unordered collection of data. myset=set(PYTHON) .Output:{'T','P','Y','H','N','O'}


Contact Us:

A-116, The Corenthum A-65,

Sector 62

Noida 201301

UP, India

Phone: +91 8882050481


© 2020 TheIkigaiLab  Terms of Use Privacy and Security Statement