Python Tutorial : Data Structures (list, dict, tuples, sets, strings)

preview_player
Показать описание
In this video I am going to show How to use different Data Structures in Python 3. The builtins data structures are: lists, tuples, dictionaries, strings, sets and frozensets.

Python Strings - 00:00:01
Python Lists - 00:12:33
Python Tuples - 00:22:32
Python Sets - 00:29:22
Python Dictionary - 00:42:58
Python Slice - 00:52:05

Data structures are particular ways of storing data to make some operation easier or more efficient.
Lists:
----------------------
A List in Python is a kind of Collection that allows us to put many values in a single “variable”. A collection is nice because we can carry all many values around in one convenient package. So What is a List? List is An ordered set of values:
Ordered: 1st, 2nd, 3rd, …
Values: can be anything, integers, strings, other lists
List values are called elements. A string is an ordered set of characters so it is “like” a list but not exactly the same thing.

Tuples:
----------------------
Python Tuples are another kind of sequence that functions similar to a list - they have elements which are indexed starting at 0. But Tuples are "immutable" i.e. Unlike a list, once you create a tuple, you cannot alter its contents.
So Tuple is an an immutable sequence which is Very similar to a list but Tuple is created it cannot be changed
Format: tuple_name = (item1, item2)
Tuples support operations as lists i.e.Subscript indexing for retrieving elements, Also Methods such as index, Built in functions such as len, min, max, Slicing expressions, The in, +, and * operators. Tuples do not support the methods like append, remove
insert, reverse, sort.
Advantages for using tuples over lists:
1)Processing tuples is faster than processing lists
2)Tuples are safe
3)Some operations in Python require use of tuples
list(tuple_var) function: converts tuple to list
tuple(list_var) function: converts list to tuple

Python Sets:
----------------------
So What are Sets in python?Sets are An unordered collection with no duplicate elements. Sets are Identified by curly braces e.g. {'Max', 'Tom', 'Den'}. Python Sets Can only contain unique elements, Duplicates are eliminated automatically at the time of initialization. Sets have no order and also Sets do not support indexing. Sets in Python can also be be used to perform mathematical set operations like union, intersection, difference and symmetric difference.

Python Dictionary:
----------------------
So What are Dictionaries in python?
dictionary in python is an associative list or a map.
We can think if dictionary as a list of pairs, where the first element of the pair, the key, is used to retrieve the second element, the value.Hence we map a key to a value.Dictionaries are Python’s most powerful data collection. Dictionaries allow us to do fast database-like operations in Python.Dictionaries are like Lists except that they use keys instead of Index to lookup values.

Python Slice:
----------------------
So What is Python Slice? A slice is a span of items that are taken from a sequence
List slicing format: list[start : end: step]. Span is a list containing copies of elements from start up to, but not including, end
If start not specified, 0 is used for start index. If end not specified, len(list) is used for end index. Slicing expressions can include a step value and negative indexes relative to end of list.
And What is Negative Indexing In Python: I a Python Collection such as Lists, Strings, Tuples, Bytes .. we can refer to an element by a negative index representing how far it is from the end.
example
# +---+---+---+---+---+---+
# | P | y | t | h | o | n |
# +---+---+---+---+---+---+
# 0 1 2 3 4 5 ---- Positive Index
# -6 -5 -4 -3 -2 -1 ---- Negative Index
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse

★★★ Online Courses to learn ★★★

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Рекомендации по теме
Комментарии
Автор

Python Strings - 00:00:01
Python Lists - 00:12:33
Python Tuples - 00:22:32
Python Sets - 00:29:22
Python Dictionary - 00:42:58
Python Slice - 00:52:05

ProgrammingKnowledge
Автор

Great nice explanation. Thank you. Please upload python with algorithms

sathishbabu
Автор

Nice but I thought turples are immutable so why did the slice function change the turple elements

iprogram
Автор

sir kindly develop a school management project step by step such like that.thank you

AhmadShah-wdyy
Автор

Already u told the same, then y once again another video? Only for of combined ds?

ManishKrSingh-ovoe